如何通过终端修复此合并

时间:2015-02-28 18:09:42

标签: git github merge git-merge

我将一个外部仓库本地拉到我的个人仓库的origin master文件夹中。除了README.md之外,来自外部文件的文件被拉了,当我拉出时我收到错误,关于我本地README.md文件的合并错误。

然后我做了一些工作,我想将我的更改推送到我的回购但是得到了

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'.

我删除了readme文件并尝试再次推送,但同样的问题。我不想add --all一次提交,因为更改是针对不同的上下文,我想分成不同的提交。

我尝试了git checkout --ours README.md--theirs README.md,然后尝试了其他操作,但仍未成功。

如何在没有UI合并工具的情况下修复此问题,但只能通过终端解决? (我在本地没有未提交的提交,atm)。

P.S。对不起,如果我搞砸了一些术语 - 我只是一个git的初学者。

Git状态:

You have unmerged paths.
  (fix conflicts and run "git commit")

Changes to be committed:

    new file:   ../bday-picker.js
    new file:   ../bday-picker.min.js
    new file:   ../index.html
    ..other files

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

    both added:         ../README.md

现在我也在想为什么列出这3个new files,因为我通过文件夹手动删除了它们......

1 个答案:

答案 0 :(得分:2)

您的git status表明您已经在合并中;你需要在再次尝试之前中止该合并。运行git merge --abort,然后再次检查git status并清理那里的任何内容,然后拉。