opike
opike

Reputation: 7595

Issue resolving conflicts in git

When I do a pull in git and have to do manual conflict resolution, I then do a rebase and I end up having to resolve the same conflicts again. I want to figure out a process where I only have to resolve the conflicts once. Here's a more detailed description of the process that currently occurs for me.

1) Do a git pull which indicates that there are conflicts with my local changes.
2) Run 'git mergetool' and manually resolve all conflicts
3) Do 'git add' and 'git commit' of the merge resolution changes.
4) Do a 'git rebase origin/master' to have my local commits placed on top.
5) Here's the issue - I get prompted to resolve the same conflicts from step 2 a second time.
6) Do a 'git rebase --continue'

I'd like to eliminate either step 2) or step 5) from this process.

Upvotes: 2

Views: 65

Answers (2)

Klas Mellbourn
Klas Mellbourn

Reputation: 44437

You could do the pull using rebase instead of merge

git pull --rebase

This will first fetch the changes to your remote branch, then it will immediately try to rebase your local commits on top of the tip of the remote branch.

That way you should only have to do one conflict resolution step.

You can configure rebase to be the default pull behavior for a branch (in this case "master"):

git config branch.master.rebase true

You can also set rebase to be the default pull behavior for all new branches in all repositories:

git config --global branch.autosetuprebase always

Upvotes: 1

Klas Mellbourn
Klas Mellbourn

Reputation: 44437

You should try git rerere

git config --global rerere.enabled true

After you have enabled rerere, Git will remember the conflict resolutions you have done, and apply them automatically the next time.

Upvotes: 4

Related Questions