Ringo
Ringo

Reputation: 838

Git <start-point> branch tracking remote automatically

From the git docs,

git checkout [-q] [-f] [-m] [[-b|-B|--orphan] <new_branch>] [<start_point>]

start_point is defined as creating the new branch based on the commit from the starting point branch or commit, but in this specific case is also creating a branch that is tracking the starting point, for example:

git checkout -b testbranch devbranch

Outputs:

Branch testbranch set up to track remote branch devbranch from origin by rebasing.

Is this expected behaviour? shouldn't the git checkout just create a local branch that is not tracking any remote branch until specified? Is this a configuration i have enabled that is triggering this behaviour?

Upvotes: 0

Views: 196

Answers (1)

Klas Mellbourn
Klas Mellbourn

Reputation: 44377

It is not expected behaviour. at last not in the way you have written your example:

git checkout -b testbranch devbranch

This should not set up any tracking even if devbranch is tracking a remote branch.

However, if you meant this command

git checkout -b testbranch origin/devbranch      

Then that would be expected to set up tracking automatically. As stated in the documentation:

This behavior is the default when the start point is a remote-tracking branch

Also, you probably have set branch.autoSetupRebase to always or pull.rebase to true since you got the message "by rebasing" (instead of the silent default to merge).

If you wish to avoid this behaviour, and create a branch from the same commit that is pointed to by a remote branch, but not tracking that remote branch, you can run this command

 git checkout --no-track -b testbranch origin/devbranch

Upvotes: 1

Related Questions