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.
Asked
Active
Viewed 338 times
12

Stevoisiak
- 23,794
- 27
- 122
- 225

Denys Mikhalenko
- 3,966
- 2
- 14
- 18
-
What version of Git are you using? – VonC Mar 24 '17 at 13:41
-
Latest at the moment, 2.12.1 – Denys Mikhalenko Mar 25 '17 at 14:55
2 Answers
2
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

Droom
- 181
- 1
- 8
1
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.

jthill
- 55,082
- 5
- 77
- 137
-
Sorry, but my question clearly states that I need a *git option* and not any other ways to achieve this functionality. That's why I mentioned aliases - to not receive answers like this one. – Denys Mikhalenko Mar 26 '17 at 13:40
-
You gave two reasons for that requirement. This satisfies the first (`git rebase` will work as you want, it doesn't introduce a new name). I suspect the second might be misworded, could you be clearer about how you expect git to behave differently for you personally when you're on "someone else's computer"? – jthill Mar 26 '17 at 18:14
-
I don't use git aliases (and explained why) and asked for a *git option*. I don't need workarounds, I only need a *git option* if it exists. – Denys Mikhalenko Mar 27 '17 at 01:49
-
3It does not. It probably should, but I doubt either of us care enough about this feature to make a patch for `git`, so unfortunately your options are aliases (shell or git) or doing without entirely. – Daniel H Mar 29 '17 at 18:18