autosetuprebase vs autosetupmerge

Git

Git Problem Overview


I was just knocking around in my global .gitconfig file and I noticed that I've managed to end up with this:

[branch]
  autosetupmerge = always
  autosetuprebase = always

That seemed more than a little counterintuitive, but after doing some reading, I still have no idea whether I need both or whether it's sufficient to remove autosetupmerge and just retain autosetuprebase. Most projects that I'm working have a straight downstream->upstream flow, so rebasing is generally preferred when dealing with branches.

Git Solutions


Solution 1 - Git

What is counterintuitive here is the naming of these preferences. They do look like they refer to the same functionality, but in fact they don't:

  • autosetupmerge controls whether git branch and git checkout -b imply the --track option, i.e. with your setting of always,
  • git checkout branchname, if branchname exists on a remote but not locally, will create branchname tracking its remote counterpart
  • git checkout -b newbranch will create a new branch newbranch tracking whichever branch you had checked out before issuing this command
  • autosetuprebase controls whether new branches should be set up to be rebased upon git pull, i.e. your setting of always will result in branches being set up such that git pull always performs a rebase, not a merge. (Be aware that existing branches retain their configuration when you change this option.)

So it makes perfect sense to have both autosetupmerge = always and autosetuprebase = always; in fact, that's also what I have.

Solution 2 - Git

since this is the first hit, if you search for "autosetuprebase" with google, here an advice:

git config --global branch.autosetuprebase always

Source https://mislav.net/2010/07/git-tips/

Solution 3 - Git

It's probably worth mentioning that there is a difference between autosetupmerge=always (in your config) and autosetupmerge=true (the default).

true will only setup merging for remote branches. always will include local branches as well.

You probably want true.

Solution 4 - Git

As I was looking for other possible options of "autosetuprebase" and it took some time to find them, here they are:

branch.autosetuprebase

When a new branch is created with git branch or git checkout that tracks another branch, this variable tells Git to set up pull to rebase instead of merge (see "branch..rebase").

  • When never, rebase is never automatically set to true.
  • When local, rebase is set to true for tracked branches of other local branches.
  • When remote, rebase is set to true for tracked branches of remote-tracking branches.
  • When always, rebase will be set to true for all tracking branches.

Source: http://git-scm.com/docs/git-config.html

Solution 5 - Git

You probably don't need to set up autosetupmerge---the default is true.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRob WilkersonView Question on Stackoverflow
Solution 1 - GitlaszlokView Answer on Stackoverflow
Solution 2 - GitguettliView Answer on Stackoverflow
Solution 3 - GitRyanKView Answer on Stackoverflow
Solution 4 - GitViacheslav KondratiukView Answer on Stackoverflow
Solution 5 - GitBruce StephensView Answer on Stackoverflow