如何使用 Git Bash 合并 "git stash pop" 冲突?

How do I merge "git stash pop" conflict by using Git Bash?

我有一个 foo.cpp 文件。 master 分支有修改,

merge conflict test, make a master modification.

同一行的分支br1上还有一个修改,

merge conflict test, make a local modification and will stash it.

现在,我在 br1 上并存储本地修改,然后我 rebase 主分支。

git rebase origin/master

然后我git stash pop本地修改,这里就冲突了,

<<<<<<< Updated upstream
merge conflict test, make a master modification.
=======
merge conflict test, make a local modification and will stash it.
>>>>>>> Stashed changes

问题来了。当我处理 Visual Studio 时,我知道我可以在 VS GUI 中单击 "merge" 按钮来编辑冲突。之后,我可以git --continue解决这个冲突。

但目前情况下,我没有VS。我不知道如何编辑冲突的命令。我可以在记事本中编辑,因为冲突很简单,但我不知道如何标记为已解决。

弹出存储后,您可以 运行 git status 获取有关您可以执行的一些操作的信息以继续前进。解决冲突后,您可以添加文件以将冲突标记为已解决:

$ git checkout master
$ <make changes to file>
$ git add file
$ git commit -m "on master, make some changes to file"
$ git checkout -b b1 HEAD~
$ <make local changes to file>
$ git stash
$ git rebase master
$ git status
  On branch b1
  Unmerged paths:
     (use "git reset HEAD <file>..." to unstage)
     (use "git add <file>..." to mark resolution)

           both modified:   file

  no changes added to commit (use "git add" and/or "git commit -a")
$ <edit file to resolve conflicts>
$ git add file
$ git reset

git reset 将取消对文件所做的所有更改。没有必要解决冲突,但它会让您回到类似于隐藏和变基之前的状态。