Reputation: 45454
When I try any of these commands:
git branch
git branch -a
git pull
git log --pretty=format:"%C(yellow)%h%Cred%d\\ %Cblue[%cn]\\%Creset %s" --decorate --graph
git log --online --decorate --graph
I get the error
fatal: Reference has invalid format: 'refs/heads/master~'
But the following commands work:
git log --oneline --graph # removed --decorate
git log
Running
find ./ -iname "*conflict*"
doesn't return any results.
The output of find ./ -name "*master*" | grep "\./\.git"
is
./.git/logs/refs/heads/master
./.git/logs/refs/heads/master~
./.git/logs/refs/remotes/origin/master
./.git/refs/heads/master
./.git/refs/heads/master~
./.git/refs/remotes/origin/master
Don't know if that helps, but I see master~
in there.
Any idea what might be wrong? What other info can I provide you with?
Upvotes: 7
Views: 9021
Reputation: 66170
The files you have found are not related to git - they are created by an editor when opening the filename without the ~
.
Just delete them, and if you want to prevent this problem in the future just configure your editor to not create swap/backup files in the same directory as the file you are editing.
Upvotes: 2
Reputation: 791361
It looks like some utility has created "backups" of the normal branch files (.git/refs/heads/...
) with a trailing ~
character. This are not allowed branch names in Git as they would conflict with the suffix notation ...~N
for obtaining ancestors.
Commands that don't need to query all refs (such as git log master
without --decorate
) are working but anything that tries to list all branches is choking on the invalid branch name.
Simply delete the file ./.git/refs/heads/master~
(after backing it up) and you should be good to go.
Upvotes: 14
Reputation: 33193
I think that your .git/HEAD file has invalid content. Check this file and if it has the tilde appended to the content remove it. For instance here on one of my repositories:
$ cat .git/HEAD
ref: refs/heads/master
Some of the files in .git are pointers to other references like this. Git reads them, dereferences the content and uses that as an object reference to go on with.
It might be that the error is on the server side - so you should check that too.
Upvotes: 2