Pullisnotpossiblebecauseyouhaveunmergedfiles.Please,fixthemupintheworktree,andthen版权声明

原创
小哥 3年前 (2022-12-30) 阅读数 11 #大杂烩

注:Git初学者的个人经验记录,仅供参考

  1. Pull is not possible because you have unmerged files.

症状:pull的时候

$ git pull

Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use git add/rm
as appropriate to mark resolution, or use git commit -a

应该是因为local文件冲突。

解决方案:

引用——

1.pull会使用git merge导致冲突,冲突文件需要resolve掉 git add -u, git commit只有在成功之后pull.

2.如果要放弃本地文件修改,可以使用git reset --hard FETCH_HEAD,FETCH_HEAD表示上次成功git pull之后形成commit点。然后git pull.
注意:

git merge会形成MERGE-HEAD(FETCH-HEAD) 。git push会形成HEAD这样的引用。HEAD表示最近的本地成功push在形成参考之后。

根据我的经验,有时这种情况会莫名其妙地发生,而且Untracked files 还有很多(事实上,我可能只更改了一两个文件),所以我必须先保存我决定制作的内容。local然后使用git reset --hard FETCH_HEAD回到最后的成功。pull在点之后,然后再次pull不会有问题的

2.You are not currently on a branch.

症状:一次pull当再次发生冲突时,这次使用“git reset --hard FETCH_HEAD“方法不好,出现:

$ git pull You are not currently on a branch, so I cannot use any branch..merge in your configuration file. Please specify which remote branch you want to use on the command line and try again (e.g. git pull ). See git-pull(1) for details.

解决方案:

首先git checkout -b temp

其次git checkout master

可以恢复master repository陈述,然后你可以pull了

原文: https://blog.51cto.com/halolk/1304701

版权声明

所有资源都来源于爬虫采集,如有侵权请联系我们,我们将立即删除