Is there an option to make git do rebase with --preserve-merges
by default? I know about aliases but I dislike the idea to remember their names and also it makes everything harder to do on someone else's computer when you get used to them.
Git's documentation for the rebase command is quite brief: --preserve-merges Instead of ignoring merges, try to recreate them. This uses the --interactive machinery internally, but combining it with the --interactive option explicitly is generally not a good idea unless you know what you are doing (see BUGS below).
After a git merge stops due to conflicts you can conclude the merge by running git merge --continue (see "HOW TO RESOLVE CONFLICTS" section below).
By default, a rebase will simply drop merge commits from the todo list, and put the rebased commits into a single, linear branch. With --rebase-merges, the rebase will instead try to preserve the branching structure within the commits that are to be rebased, by recreating the merge commits.
After starting a rebase, Git creates an anonymous branch and starts applying commits to it. Since ours means "keep changes from the current branch", that current branch will be HEAD , which contains upstream and any changes already applied by rebase .
If you want to do this when you pull (say, develop), you can do this in git >= 1.7.9::
git config pull.rebase preserve
It will make all your pull actions to rebase the branch from remote into your local one and preserve merges.
It does not work if you want to rebase develop into another branch.
In git < 1.7.9:
git config --global branch.autosetuprebase always
See Make git pull --rebase preserve merge commits
This kind of idiosyncratic need is one of the reasons shell functions exist.
git() {
case $1 in
rebase) shift; set -- rebase --preserve-merges "$@" ;;
esac
command git "$@"
}
As for
I know about aliases but I dislike the idea to remember their names and also it makes everything harder to do on someone else's computer when you get used to them.
I think a method for getting a command to behave differently on someone else's computer, but only when you use it, would have to be asked as a separate question for a proper response.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With