Accept Your Own Changes During Git Rebase
During a git rebase
you may encounter conflicts in files between your current, HEAD
, branch and the branch you're rebasing. Ordinarily, you'll want to go through each file and individually resolve each conflict to ensure that the proper changes are preserved.
Sometimes, however, you already know that you want to accept ALL the changes in a file on your local branch and discard the other branch's edits. Instead of opening the file, finding the conflict regions, then making the appropriate changes, you can more succinctly prefer your changes with the following command:
Conversely, if you want to keep the other branch's changes, run:
You can also do this for an entire directory:
When you [re]open the conflict files, you'll see that your preferred branch's changes have been written and the other branch's have been discarded.
After you've finished, stage the the conflict files, and continue your rebase:
Tweet