How do I finish the merge after resolving my merge conflicts?

How do I finish the merge after resolving my merge conflicts?

With Git 2.12 (Q1 2017), you will have the more natural command:

git merge --continue

And if you don't want to edit the message when continuing/resuming the merge:

git merge --continue --no-edit

If --no-edit does not work, as akseli reported in the comments, you can do:

# Linux
GIT_EDITOR=true git merge --continue

# Windows
cmd /V /C "set "GIT_EDITOR=true" && git merge --continue"

You can define an alias for those commands.


See commit c7d227d (15 Dec 2016) by Jeff King (peff).
See commit 042e290, commit c261a87, commit 367ff69 (14 Dec 2016) by Chris Packham (cpackham).
(Merged by Junio C Hamano -- gitster -- in commit 05f6e1b, 27 Dec 2016)

See 2.12 release notes.

merge: add '--continue' option as a synonym for 'git commit'

Teach 'git merge' the --continue option which allows 'continuing' a merge by completing it.
The traditional way of completing a merge after resolving conflicts is to use 'git commit'.
Now with commands like 'git rebase' and 'git cherry-pick' having a '--continue' option adding such an option to 'git merge' presents a consistent UI.


When there is a conflict during a merge, you have to finish the merge commit manually. It sounds like you've done the first two steps, to edit the files that conflicted and then run git add on them to mark them as resolved. Finally, you need to actually commit the merge with git commit. At that point you will be able to switch branches again.

Quick Tip: You can use git commit -am "your commit message" to perform add and commit operations on tracked files simultaneously. (Credit: @vaheeds)


In case you ever get stuck during a merge/rebase you can always

git reset --hard

to restore your working to the state of the last commit. This will lose your changes from the working tree so if you had local modifications before the merge they will be gone after this—which is why it’s advisable to not start a merge when you have local modifications. :)


Just git commit it.

Optionally git abort it:
I ran into a merge conflict. How can I abort the merge?

To make life easier with on merges install kdiff3 and configure it as a mergetool. Instructions: http://doodkin.com/2016/05/29/git-merge-easy-github-this-branch-has-conflicts-that-must-be-resolved-use-the-command-line/

That page contains this video: https://www.youtube.com/watch?v=Cc4xPp7Iuzo

Tags:

Git

Git Merge