我正在使用Dropbox同步git存储库,但现在当我尝试并且push我收到错误时:
fatal: Reference has invalid format: 'refs/heads/master (MacBook-Pro's conflicted copy 2012-10-07)'
Run Code Online (Sandbox Code Playgroud)
因此,似乎Dropbox检测到冲突并创建了副本.好的,没问题,所以我删除了冲突的文件.尽管如此,仍然可以获得上述git错误.
$ git checkout master
M index.html
Already on 'master'
$ git add .
$ git commit -a -m "Cleanup repo"
[master ff6f817] Cleanup repo
1 file changed, 5 insertions(+), 5 deletions(-)
$ git push
fatal: Reference has invalid format: 'refs/heads/master (MacBook-Pro's conflicted copy 2012-10-07)'
The remote end hung up unexpectedly`
Run Code Online (Sandbox Code Playgroud)
我怎样才能解决这个问题?谢谢.
Lan*_*ane 178
如果您不确定这个,请备份您的仓库,因为这些命令是不可逆转的.
首先,转到您的repo目录.
cd myrepo
Run Code Online (Sandbox Code Playgroud)
然后递归搜索冲突的文件并删除它们
find . -type f -name "* conflicted copy*" -exec rm -f {} \;
Run Code Online (Sandbox Code Playgroud)
最后,从git的packed-refs文件中删除任何"冲突的"引用
awk '!/conflicted/' .git/packed-refs > temp && mv temp .git/packed-refs
Run Code Online (Sandbox Code Playgroud)
Mar*_*nde 42
冲突的文件可能在多个地方,我会调查:
.git/logs/refs/remotes/origin/
.git/logs/refs/heads/
.git/refs/remotes/origin/
.git/refs/heads/
Run Code Online (Sandbox Code Playgroud)
或者您可能会在.git子目录中的任何位置查找:find . -name '*conflicted*'
或者,否则,列出活动分支git branch -a和删除(git branch -d)任何可疑的分支.
当我的同事在Dropbox更新之前推送他的更改并关闭PC时,我们的团队也会遇到这种情况.
我这么简单地解决了.
刚刚删除了冲突的副本.(XXXX的冲突副本yyyy-mm-dd)
并正常拉.
请注意,我的同事在搞砸之前已经做了更改.他再次推动他的改变.这次没有关机.:)