简体   繁体   English

拉不可能,因为你有未合并的文件,git stash不起作用。不想承诺

[英]Pull is not possible because you have unmerged files, git stash doesn't work. Don't want to commit

I just want to pull. 我只是想拉。 I have changes to disregard, my Gemfile and Gemlock files and I'd be happy to just overwrite them and just pull. 我有更改无视,我的Gemfile和Gemlock文件,我很乐意只是覆盖它们而只是拉。 I tried stashing my changes away, this didn't work out for me. 我试着把我的变化藏起来,这对我来说没有用。 What do I do? 我该怎么办?

git pull
M   Gemfile
U   Gemfile.lock
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.
~/projects/sms/apps2/apps2_admin(apps2)$ git stash save "saved"
Gemfile.lock: needs merge
Gemfile.lock: needs merge
Gemfile.lock: unmerged (4ea16799dba7bfe1db28adecf36dee1af5195c1a)
Gemfile.lock: unmerged (e77439c9f86d1d0eda7ae0787e3e158f90959e68)
Gemfile.lock: unmerged (d690d3860db1aa8e46c1bb2f4de3e52a297b5c26)
fatal: git-write-tree: error building trees
Cannot save the current index state
~/projects/sms/apps2/apps2_admin(apps2)$ git pull
M   Gemfile
U   Gemfile.lock
Pull is not possible because you have unmerged files.
Please, fix them up in the work tree, and then use 'git add/rm <file>'
as appropriate to mark resolution, or use 'git commit -a'.
git fetch origin
git reset --hard origin/master
git pull

Explanation: 说明:

  • Fetch will download everything from another repository, in this case, the one marked as "origin". Fetch将从另一个存储库下载所有内容,在本例中为标记为“origin”的存储库。
  • Reset will discard changes and revert to the mentioned branch, "master" in repository "origin". 重置将丢弃更改并恢复到存储库“origin”中提到的分支“master”。
  • Pull will just get everything from a remote repository and integrate. Pull将从远程存储库中获取所有内容并进行集成。

See documentation at http://git-scm.com/docs . 请参阅http://git-scm.com/docs上的文档。

您可以使用git checkout <file>的已提交版本(从而丢弃您的更改),或者git reset --hard HEAD以丢弃所有文件的任何未提交的更改。

I've tried both these and still get failure due to conflicts. 我已经尝试了这两种方法,但由于冲突仍然会失败。 At the end of my patience, I cloned master in another location, copied everything into the other branch and committed it. 在我的耐心结束时,我在另一个位置克隆了主人,将所有内容复制到另一个分支并提交了它。 which let me continue. 让我继续。 The "-X theirs" option should have done this for me, but it did not. “-X他们的”选项应该为我做到这一点,但事实并非如此。

git merge -s recursive -X theirs master git merge -s recursive -X他们的主人

error: 'merge' is not possible because you have unmerged files. 错误:由于您有未合并的文件,因此无法进行“合并”。 hint: Fix them up in the work tree, hint: and then use 'git add/rm ' as hint: appropriate to mark resolution and make a commit, hint: or use 'git commit -a'. 提示:将它们修复到工作树中,提示:然后使用'git add / rm'作为提示:适合标记解析并进行提交,提示:或使用'git commit -a'。 fatal: Exiting because of an unresolved conflict. 致命的:由于未解决的冲突而退出。

我有同样的错误,我解决它: git merge -s recursive -X theirs origin/master the git merge -s recursive -X theirs origin/master

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM