I have a private server running git 1.7 When I
git init
a folder it doesn't create a master branch. Cause when i do:
git branch
it doesn't list anything. When I do:
git --bare init
it creates the files. When I type
git branch master
it says:
fatal: Not a valid object name: 'master'.
This question is related to
git
Git creates a master branch once you've done your first commit. There's nothing to have a branch for if there's no code in the repository.
You need to commit at least one time on master before creating a new branch.
copying Superfly Jon's comment into an answer:
To create a new branch without committing on master
, you can use:
git checkout -b <branchname>
First off, when you create a "bare repository", you're not going to be doing any work with it (it doesn't contain a working copy, so the git branch
command is not useful).
Now, the reason you wouldn't have a master
branch even after doing a git init
is that there are no commits: when you create your first commit, you will then have a master
branch.
Source: Stackoverflow.com