Skip to content

Instantly share code, notes, and snippets.

@Trott
Created May 27, 2022 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Trott/25051edaa92e31baab9ff4043231f0dd to your computer and use it in GitHub Desktop.
Save Trott/25051edaa92e31baab9ff4043231f0dd to your computer and use it in GitHub Desktop.
Rebasing away merge conflicts
$ git fetch upstream
$ git fetch origin
$ git checkout feature-branch
$ git rebase origin/feature-branch
$ git rebase upstream/main

Oh noes! A merge conflict appears here!

Open the file with the conflict, find the conflict markers (>>>>>> and <<<<<<) and figure out what the correct change is.

Sometimes it's really easy.

Sometimes it's not.

Once you've resolved the merge conflict and saved changes (and maybe run tests and a linter to make sure you haven't introduced errors)...

$ git rebase --continue

Now you can run tests and a linter (if you didn't before--or even if you did). Then push (with --force or --force-with-lease probably).

Merge conflict gone. Hooray. 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment