首页 > 解决方案 > 如何解决git中的分歧?

问题描述

我在解决我的工作副本上遇到的问题时遇到了麻烦:早些时候我拉动并自动合并了几个文件,然后它们出现在我没有提交的暂存区域中。我现在恢复了文件中的更改,git checkout -- my/file当天晚些时候,我想再拉一次,但它不能,我收到如下错误:

$ git pull
error: You have not concluded your merge (MERGE_HEAD exists).
hint: Please, commit your changes before merging.
fatal: Exiting because of unfinished merge.

我该如何解决这种情况?我不想在这个分支上提交任何东西!我也得到:

$ git status
On branch dev
Your branch and 'origin/dev' have diverged,
and have 3 and 4 different commits each, respectively.
  (use "git pull" to merge the remote branch into yours)
All conflicts fixed but you are still merging.
  (use "git commit" to conclude merge)

Untracked files:
  (use "git add <file>..." to include in what will be committed)

标签: gitmergeversion-controlgit-branch

解决方案


首先,git merge --quitGit 2.23+)应该有助于摆脱正在进行的合并。

其次,git pull --rebase应该有助于在更新的origin/dev.

然后就可以推了。

OP BitFreak使其工作(见评论):

git push --abort
git pull --rebase

推荐阅读