Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

autosetuprebase vs autosetupmerge

Tags:

git

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.

like image 606
Rob Wilkerson Avatar asked Mar 29 '11 23:03

Rob Wilkerson


People also ask

What is Autosetuprebase?

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.)

What git pull rebase do?

Git pull rebase is a method of combining your local unpublished changes with the latest published changes on your remote. Let's say you have a local copy of your project's main branch with unpublished changes, and that branch is one commit behind the origin/main branch.


1 Answers

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.

like image 161
laszlok Avatar answered Nov 16 '22 01:11

laszlok