2

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.

3
  • You have to use git add <path_to_file> to add it to the index. That marks the conflict as resolved and you can use git merge --continue to continue the merge. Commented Jun 20, 2019 at 8:50
  • @kowsky, I have looked up this too. git add <path_to_file> can work, but git merge --continue turned out error: unknown option `continue' Commented Jun 20, 2019 at 8:52
  • 4
    If you don't have git merge --continue, your Git is fairly old (run git --version to get its version number). All git merge --continue does, though, is verify that there is a merge to finish, then run git commit—so you can just run git commit since you don't have the --continue option. Commented Jun 20, 2019 at 9:00

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.