0

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?

1
  • 1
    You set branch.autoSetupRebase to true. Commented Feb 7, 2019 at 23:41

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.