Have you ever rebased a branch resolving many conflicts on multiple commits?
Yes, that's a sad story.
It wouldn't be so sad, if it was a merge instead, because in case of merge
we have to fix only final conflicts in just one step.
So here is an idea how to how make potentially hard rebase easier:
- Start a hidden merge
- Resolve conflicts and save hidden merge result
- Perform a standard branch rebase, but with automatic conflict resolution
- Restore hidden result as single additional commit
This script implements this approach as simple dialog and applicable on Linux / Mac / Windows (git-bash).
First, get the script and make it executable
curl -L https://git.io/rebase-via-merge -o ~/git-rebase-via-merge.sh
chmod +x ~/git-rebase-via-merge.sh
Change default base branch if needed by editing this line
nano ~/git-rebase-via-merge.sh
default_base_branch='origin/master'
Every time you want to do rebase, just run
~/git-rebase-via-merge.sh
instead of
git rebase origin/master
If you want to test this script, just run it on temp branch
git checkout -b test-of-rebase-via-merge
Also you can specify base branch like this:
~/git-rebase-via-merge.sh origin/develop