Saturday, December 4, 2010

Git Gotta

>> mkdir foo
>> git init
Initialized empty Git repository in /home/jianlu/repos/web/foo/.git
>> git branch master
fatal: Not a valid object name: 'master'.

// How to fix this?
// make an arbitrary checkin by git submit. You are done.

Update:
git commit --allow-empty -m "initial commit"

Source of this update: (thanks to Mohamed Meligy's tip)

>> git branch
master.

Git claims this to be by design because before the user makes the first initial commit, there is nothing to be branched.

This kinda makes sense but not always a valid restriction. It is not a rare case that you want to lay out your repository structure because you know the repro structure should be like that even before you write the first line of your project code.

and btw, this is a terrible error message. It barely says anything about the real cause of this failure, or any suggestion on possible fixes.