Specify pull reconciliation differently per branch on gitconfig

Viewed 59

After updating to Git 2.28 I realized the conditional includes. However I was unable to find a way to set a different pull reconciliation option for master(main) other than the rest.

So for the master(main) branch I want to have --ff-only while for other branches I'd go with --rebase

Is there a way to do it inside the main .gitconfig file, just using onbranch?

The only solution I was able to come up with was:

.gitconfig

[includeIf "onbranch:master"]
   path = ~/.gitconfigmaster

and then create a .gitconfigmaster having:

[pull]
   ff = only
1 Answers

A better fit would probably be to use the branch.* options :

# default '--rebase' for everyone :
git config pull.rebase true

# for the 'master' branch: override the global 'pull.rebase' option
git config branch.master.rebase false
git config branch.master.mergeOptions --ff-only
Related