j-pb
j-pb

Reputation: 842

"git branch --track" vs "git checkout --track"

What is the difference between "git branch --track" and "git checkout -b --track", if there is any?

Upvotes: 9

Views: 4077

Answers (3)

theunraveler
theunraveler

Reputation: 3284

If I'm not mistaken, git checkout ... will actually create the branch AND switch your working copy to that branch, while git branch ... will just create the branch and leave your working copy alone.

Upvotes: 6

Jungle Hunter
Jungle Hunter

Reputation: 7285

Internally git-branch is called and then the new branch is checked out. From the docs.

If -b is given, a new branch is created as if git-branch were called and then checked out; in this case you can use the --track or --no-track options, which will be passed to git branch. As a convenience, --track without -b implies branch creation; see the description of --track below.

Upvotes: 7

Michael Madsen
Michael Madsen

Reputation: 54989

According to the documentation for git checkout, there should be no difference.

-b Create a new branch named <new_branch> and start it at <start_point>; see git-branch(1) for details.

Upvotes: 1

Related Questions