Note: This will not work with Ubuntu 12.04, as the support for gitosis is removed in this release. See http://askubuntu.com/questions/126097/ubuntu-12-04-gitosis-no-longer-available for details. For migration from gitosis to gitolite, see this blog post: http://www.sureshpw.com/2012/05/migrating-from-gitosis-to-gitolite-on.html
There are a number of articles and blogs on how to use Git. But not very much information on how to setup your own Git server. Here are the steps on how to setup your Git server using gitosis on Ubuntu and use a Git client from Windows (cygwin in my case).
git-server: The server where the git repository is hosted.
git-client: The windows client accessing git
gituser: Windows user name using the git client
git: The username under which the git repository is created on the git-server.
First of all make sure that the Ubuntu server has the latest updates and install the required tools
Commit and push the new changes to gitosis.conf file.
There are a number of articles and blogs on how to use Git. But not very much information on how to setup your own Git server. Here are the steps on how to setup your Git server using gitosis on Ubuntu and use a Git client from Windows (cygwin in my case).
git-server: The server where the git repository is hosted.
git-client: The windows client accessing git
gituser: Windows user name using the git client
git: The username under which the git repository is created on the git-server.
First of all make sure that the Ubuntu server has the latest updates and install the required tools
git-server> sudo apt-get update git-server> sudo apt-get dist-upgrade git-server> sudo apt-get install python-setuptoolsInstall gitosis and add user named git on the git-server who will manage the git repository.
git-server> sudo apt-get install git-core gitosis git-server> sudo adduser --system --shell /bin/sh --gecos 'git version control' \ --group --disabled-password --home /home/git gitOn the client machine, create a SSH public/private key for the user to access Git. Then provide permissions on the git server for this user.
git-client> ssh-keygen -t rsaThis will create private/public keys under $HOME/.ssh directory. On a cygwin platform, it will be under /home/gituser directory. Now upload the public key to git-server.
git-client> scp /home/gituser/.ssh/id_rsa.pub gitadmin@git-server:/tmp/Initialize gitosis admin repository
git-server> sudo -H -u git gitosis-init < /tmp/id_rsa.pub git-server> sudo chmod 755 /home/git/repositories/gitosis-admin.git/hooks/post-updateAdd your new project to git by modifying the git-admin configuration.
git-client> git clone git@git-server:gitosis-admin.git git-client> cd gitosis-admin git-client> vi gitosis.confThe gitosis.conf has one project, gitosis-admin. Duplicate the [gitosis-admin] section and modify for your new project. The results will be as given below:
Commit and push the new changes to gitosis.conf file.
git-client> git commit -a -m 'Added new project my-new-project' git-client> pushImport files to the new project
git-client> cd my-new-project git-client:~/my-new-project/> git init git-client:~/my-new-project/> git add . git-client:~/my-new-project/> git commit -m 'Initial import of files to my-new-project' git-client:~/my-new-project/> git remote add origin git@git-server:my-new-project.git git-client:~/my-new-project/> git push -u origin masterNow the project is available in the remote git repository. Any new user can get the code by simply cloning the repository
git clone git@git-server:my-new-project.git
References
- http://www.hackido.com/2010/01/installing-git-on-server-ubuntu-or.html
- http://blog.jasonmeridth.com/2010/05/22/gitosis-and-gitweb-part-1.html
- http://thelucid.com/2008/12/02/git-setting-up-a-remote-repository-and-doing-an-initial-push/
- https://help.ubuntu.com/community/Git
gitosis is no longer available in precise pangolin (12.04).
ReplyDeleteSee: http://askubuntu.com/questions/126097/ubuntu-12-04-gitosis-no-longer-available
I am running Ubuntu 11.10. Didn't realize that they have removed the support for gitosis in 12.04. Thanks for the information.
ReplyDelete