git init --bare test-repo.git
cd test-repo.git
(Folder is created with git-ish files and folders inside)
git status
fatal: This operation must be run in a work tree
(Okay, so I can't use git status with a bare repo; makes sense I guess)
git branch
(Nothing, it seems the bare repo doesn't contain any branches. Do I have to add them from a cloned repo?)
cd ..
mkdir test-clone
cd test-clone
git clone ../test-repo.git
(I get a warning about cloning an empty repository)
cd test-repo
(The prompt changes to indicate I am on the master branch)
git branch
(Shows no results – eh?)
git branch master
fatal: Not a valid object name: 'master'
Um. So how do I create the master branch in my bare repo?
Best Solution
A bare repository is pretty much something you only push to and fetch from. You cannot do much directly "in it": you cannot check stuff out, create references (branches, tags), run
git status
, etc.If you want to create a new branch in a bare Git repository, you can push a branch from a clone to your bare repo: