致命:参考格式无效:'refs/heads/master~'

tru*_*ktr 7 git

当我尝试以下任何命令时:

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
Run Code Online (Sandbox Code Playgroud)

我收到了错误

fatal: Reference has invalid format: 'refs/heads/master~'
Run Code Online (Sandbox Code Playgroud)

但以下命令有效:

git log --oneline --graph # removed --decorate
git log
Run Code Online (Sandbox Code Playgroud)

运行

find ./ -iname "*conflict*"
Run Code Online (Sandbox Code Playgroud)

不会返回任何结果.

输出find ./ -name "*master*" | grep "\./\.git"

./.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
Run Code Online (Sandbox Code Playgroud)

不知道这是否有帮助,但我master~在那里看到了.

知道什么可能是错的吗?我可以为您提供哪些其他信息?

CB *_*ley 13

看起来某个实用程序已创建.git/refs/heads/...带有尾随~字符的普通分支文件()的"备份" .这在Git中不允许使用分支名称,因为它们会与...~N用于获取祖先的后缀表示法冲突.

不需要查询所有引用(例如git log master--decorate)的命令正在运行,但尝试列出所有分支的任何内容都会阻塞无效的分支名称.

只需删除文件./.git/refs/heads/master~(备份后),你应该好好去.