【问题标题】:Pull is not possible because you have unmerged files, git stash doesn't work. Don't want to commit无法拉取,因为您有未合并的文件, git stash 不起作用。不想承诺
【发布时间】:2011-12-24 02:04:10
【问题描述】:

我只想拉。我有一些更改要忽略,我的 Gemfile 和 Gemlock 文件,我很乐意覆盖它们并拉取。我试着把我的改变藏起来,这对我没有用。我该怎么办?

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 git-pull git-stash


【解决方案1】:
git fetch origin
git reset --hard origin/master
git pull

解释:

  • Fetch 将从另一个存储库下载所有内容,在本例中,即标记为“来源”的存储库。
  • 重置将放弃更改并恢复到提到的分支,即存储库“origin”中的“master”。
  • Pull 只会从远程存储库中获取所有内容并进行集成。

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

【讨论】:

  • 这到底是做什么的?
  • Fetch 将从另一个存储库下载所有内容,在本例中,即标记为“origin”的存储库。重置将丢弃更改并恢复到存储库“origin”中的提到的分支“master”。 Pull 只会从远程存储库中获取所有内容并进行集成。请参阅git-scm.com/docs 上的文档。
【解决方案2】:

您可以使用git checkout &lt;file&gt; 来检查文件的已提交版本(从而丢弃您的更改),或使用git reset --hard HEAD 丢弃所有文件的任何未提交更改。

【讨论】:

    【解决方案3】:

    我已经尝试了这两种方法,但由于冲突仍然失败。在我的耐心结束时,我将 master 克隆到另一个位置,将所有内容复制到另一个分支并提交。这让我继续。 “-X theirs”选项应该为我完成了这个,但它没有。

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

    错误:“合并”是不可能的 因为你有未合并的文件。提示:在工作树中修复它们, 提示:然后使用 'git add/rm' 作为提示:适合标记 解决并做出承诺, 提示:或使用 'git commit -a'。致命的: 由于未解决的冲突而退出。

    【讨论】:

      【解决方案4】:

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

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2021-04-02
        • 1970-01-01
        • 2020-10-25
        • 1970-01-01
        • 2018-06-17
        • 2015-07-10
        相关资源
        最近更新 更多