【问题标题】:"Pull is not possible because you have unmerged files" - how do I fix this?“无法提取,因为您有未合并的文件” - 我该如何解决这个问题?
【发布时间】:2016-12-10 23:01:25
【问题描述】:

我在这个网站上发现了一些类似的问题,但事实是我几乎不知道自己在做什么,也无法跟上答案。

我正在尝试将一名员工添加到我的公司网站。我写的时候

$ git pull origin gh-pages

它显示了所有这些:

Laurences-MacBook-Pro-2:opennorth.ca Laurence$ git pull origin gh-pages
M   _data/staff.yml
M   _layouts/default.html
D   _posts/2013-04-05-this-week-in-open-government.md
A   _posts/2016-04-11-open-north-newsletter-spring-2016.md
A   _posts/2016-05-05-launching-and-sustaining-municipal-open-data-initiatives-how-open-north-can-help.md
A   _posts/2016-06-01-open-cities-strategies-a-new-initiative-by-open-north-to-help-cities-succeed-in-planning-and-implementing-their-open-data-programs.md
A   _posts/2016-06-08-spreading-the-word-about-citizen-budget-our-innovative-online-budget-simulator.md
A   _posts/2016-06-15-applied-research-in-action-immigration-refugee-and-citizenship-canada.md
A   _posts/2016-07-07-exploring-the-social-sector-s-relationship-with-data-takeaways-from-data-4-impact.md
M   index.html
U   theme
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 and make a commit.
Laurences-MacBook-Pro-2:opennorth.ca Laurence$ 

这些是另一位员工(对 Github 也知之甚少)通过 Prose.io 发布的博客文章。我认为她缺少将文件合并到原始分支的某种步骤?

我不想删除所有这些帖子,但我不知道如何在工作树中修复它们。

非常感谢任何帮助,用超级蹩脚的话。

这是 git status 的结果:

On branch gh-pages
Your branch and 'origin/gh-pages' have diverged,
and have 1 and 65 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)
You have unmerged paths.
  (fix conflicts and run "git commit")

Changes to be committed:

    modified:   _data/staff.yml
    modified:   _layouts/default.html
    deleted:    _posts/2013-04-05-this-week-in-open-government.md
    new file:   _posts/2016-04-11-open-north-newsletter-spring-2016.md
    new file:   _posts/2016-05-05-launching-and-sustaining-municipal-open-data-initiatives-how-open-north-can-help.md
    new file:   _posts/2016-06-01-open-cities-strategies-a-new-initiative-by-open-north-to-help-cities-succeed-in-planning-and-implementing-their-open-data-programs.md
    new file:   _posts/2016-06-08-spreading-the-word-about-citizen-budget-our-innovative-online-budget-simulator.md
    new file:   _posts/2016-06-15-applied-research-in-action-immigration-refugee-and-citizenship-canada.md
    new file:   _posts/2016-07-07-exploring-the-social-sector-s-relationship-with-data-takeaways-from-data-4-impact.md
    modified:   index.html

Unmerged paths:
  (use "git add <file>..." to mark resolution)

    both modified:   theme

Laurences-MacBook-Pro-2:opennorth.ca Laurence$ 

谢谢! 劳伦斯

【问题讨论】:

标签: git


【解决方案1】:

如果您所做的更改相对较小,最简单的方法可能是首先存储您的更改,执行拉取,然后重新应用存储。此时您可以解决任何冲突。

git stash
git pull origin gh-pages
git stash pop

【讨论】:

    【解决方案2】:

    当您的 git 存储库中包含尚未“保存”的更改时,您不能执行像 git pull 这样的破坏性操作 - 否则,您将丢失当前正在执行的所有内容!

    您可以在这里做以下两件事之一:

    • 要么通过运行 git stash 保存现有更改以备后用,要么
    • 提交并保存您现有的更改,例如:git add --all; git commit

    完成上述任一操作后,您就可以随意拉取分支更改。

    【讨论】:

    • git reset --hard 如果您不介意丢失更改。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-10-25
    • 1970-01-01
    • 2018-03-24
    • 1970-01-01
    • 2020-03-25
    • 2020-02-14
    相关资源
    最近更新 更多