Denys Mikhalenko
Denys Mikhalenko

Reputation: 4264

Git option for `--preserve-merges`?

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.

Upvotes: 12

Views: 360

Answers (2)

Droom
Droom

Reputation: 191

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

Upvotes: 2

jthill
jthill

Reputation: 60585

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.

Upvotes: 1

Related Questions