Thursday, February 03, 2011


Creating a bare git repo and avoiding the no master branch problem

I was creating a bare git repo today that would serve as the pristine copy that all others would clone from.

I was doing something like:

  1. umask 0000 # Because I wanted the pristine copy to be world writable
  2. git init --bare --shared=all ~/reponame.git
  3. cd somewhere
  4. git clone ~/reponame
  5. cd reponame
  6. touch foo
  7. git add foo
  8. git commit -m test foo
  9. git push
Unfortunately, my push attempt was rebuffed with the following error message:
No refs in common and none specified; doing nothing.
Perhaps you should specify a branch such as 'master'.
fatal: The remote end hung up unexpectedly
error: failed to push some refs to '/path/to/reponame.git
What I had to do was at that last step was
  1. git push origin master
That created the master branch in the pristine repo. Subsequent clones didn't have to go to that trouble.

This page is powered by Blogger. Isn't yours?