Howto setup and populate a git server on Gentoo
Gentoo, git, Guide, Linux, Server
WARNING: This howto is now old and deprecated! Check the newer version linked to below for a current working howto:
So I went back and got my git server working 100%. Reread some docs and now everything is working quite well. It’s pretty nice.
To get a git server setup, emerge dev-utils/git and cogito. Cogito is a “front end” of sorts for git. It supplies some better commands in some cases. Then run
and you now have a git server. Yes, it’s that easy.
Of course you don’t have anything in it and you aren’t quite setup to, but it’s fine to have the server running with a somewhat empty system. Next create a directory to store your git repositories, like /git. Now all you have to do is create repositiories, which is made very easy by the command
cg-admin-setuprepo -g git /git/repoName
‘git’ being a user group that committers on the system will be members of so that they can all have write access. Now of course you have an empty repository. Also, you have a non shared repository. Other system users/’committers’ can access it, but it’s not exported by the git server. To do that, simply
To populate the repository, change into a directory where you have the code you want to go into the repository. This can be on any computer, not necessarily the server. We will set up more git stuff ‘client’ side and then ‘commit’ it to the git server. So where ever the code is, you need ssh access from that location to an account on the git server that is a member of the ‘git’ group that can write to the repository. Now, once if the code directory, set it up as a git repository with
If all went well you now have a local git respiratory of the code. It might give you an error involving AUTHOR_NAME and COMMITTER_NAME. IF this happens it is because the name field for your user account is blank. Edit /etc/passwd and add a name (can be the same as the account name) to the 5th field of the account you are using. Now it should work (rm -r .git to restart). Now to connect the local repository to the server and update the server, we do as follows, first we add a branch to the local repository that is connected to the server.
cg-branch-add origin git+ssh://serverName.com/git/repoName
Now they are connected. ‘origin’ will be the default branch (I believe it’s a special branch, whose purpose should be obvious). Now just update the server.
Done. Now you have a git server with a repository of your code. You can update the repository with further changes by
Other non-system/non-commit users can access the repository with
git clone git://serverName.com/git/repoName
and once in it they can update it from the server with
And there you have it, how to set up a git server on Gentoo and populate it.