views:

58

answers:

3

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

A: 

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.

Michael Madsen
... apart from the obvious difference that checkout also checks the branch out.
Charles Bailey
+1  A: 

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.

Ashish
+2  A: 

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.

theunraveler