Monday, March 28, 2011

Wednesday, March 16, 2011

GIT: Pushing a new repository to a git server the first time

You created some local repository and worked on that for a while. Now you want to have it on a server so that others can collaborate.
We want to keep the full history so we want to push the current repository to the server. In order to do this at least for the master branch you have to edit the config file at:
It probably looks like the following:
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true

The easiest way to get everything right is to check out the empty repository from the server via git clone and diff the two config files.
Finally you see that you have to add something like:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url =
[branch "master"]
remote = origin
merge = refs/heads/master

To the existing config.

Now issue a git push origin master and the master will be pushed.
If you know whether that works with branches as well or how to get that working, please drop me a comment!?

There are other ways to just give the repository as a argument at the git push command but I like to keep my old directories.