I created a bare repository on a file-server in my local network at home.
After this i pushed a branch of an existing repository from my desktop-pc to this new remote repository.
Pushing worked perfectly and it seems, that all data arrived (a “git branch -va” gives me the correct data).
But i cannot use git log or git show on the bare repository.
i get an:
fatal: bad default revision 'HEAD'
or simply no output
is this normal for bare repositories? Is there another possibility to visualize everything?
Edit:
The fatal error is solved now, but i receive no output from “git log” or “git log unstable”. Same command on the desktop-pc works perfectly
Yes, this is normal for new bare (and non-bare) repositories.
Explanation
HEADis what Git calls a symbolic reference—a reference to another reference.In non-bare repositories,
HEADnormally indicates which branch is currently checked out. A new commit will cause the branch named byHEADto be advanced to refer to the new commit. WhenHEADrefers to a commit object directly instead of a branch, it’s considered to be detached, meaning further commits will not cause a branch reference to be advanced to refer to the new commits (dangerous because checking out a different commit or branch will render the new commits unreachable by any existing reference, making them hard to find and subject to garbage collection).In bare repositories,
HEADindicates the repository’s default branch, so that in a clone of the repositorygit checkout originis equivalent togit checkout origin/masterifmasteris the default branch (seegit help rev-parsefor details).When Git initializes a new repository, it initializes
HEADto refer torefs/heads/master(in other words,HEADpoints to themasterbranch by default). However, it does not create a branch namedmasterbecause there are no commits in the repository formasterto point to yet.So until you either create a
masterbranch or changeHEADto point to a branch that does exist, you’ll get that error when you run a command that looks atHEAD(such asgit logorgit showwithout any arguments).You can still use commands that don’t examine
HEAD. For example:Fix
To get rid of the error message, you can do one of the following:
Change
HEADto point to a branch that does exist:masterbranch into the repository from somewhere elseCreate a new
masterbranch locally:Visualization
To visualize everything in the repository, I use something like this:
Note that the above command will work even if
HEADis pointing to a non-existent branch.