Zhang
Zhang

Reputation: 3356

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

I have a foo.cpp file. There is a modification on master branch,

merge conflict test, make a master modification.

There is another modification on the branch br1 in the same line,

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

Now, I'm on br1 and stash the local modification, then I rebase the master branch.

git rebase origin/master

Then I git stash pop the local modification, here I get the conflict,

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

Here's the problem. When I working on Visual Studio, I know I can click "merge" button within the VS GUI to edit the conflict. After that, I can git --continue to go through this conflict.

But in current situation, I don't have VS. I don't how the command to edit the conflict. I can edit it in notepad, because the conflict is simple, but I don't know how to mark it as resolved.

Upvotes: 2

Views: 3540

Answers (1)

joran
joran

Reputation: 2883

After you have popped the stash you can run git status to get information on some actions you can perform to go forward. After you have resolved the conflicts you can add the file to mark the conflict as resolved:

$ 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

The git reset will unstage all changes made to the file. It's not necessary to resolve the conflicts, but it will set you back to a state similar to the one you had before the stash and rebase.

Upvotes: 1

Related Questions