47
Running `git checkout` without specifying a branch has no effect except
48
to print out the tracking information for the current branch.
49
50
-`git checkout (-b|-B) <new-branch> [<start-point>]`::
51
-
52
- Specifying `-b` causes a new branch to be created as if
53
- linkgit:git-branch[1] were called and then checked out. In
54
- this case you can use the `--track` or `--no-track` options,
55
- which will be passed to `git branch`. As a convenience,
56
- `--track` without `-b` implies branch creation; see the
57
- description of `--track` below.
58
-+
59
-If `-B` is given, _<new-branch>_ is created if it doesn't exist; otherwise, it
60
-is reset. This is the transactional equivalent of
61
-+
62
-------------
63
-$ git branch -f <branch> [<start-point>]
64
-$ git checkout <branch>
65
-------------
50
+`git checkout -b <new-branch> [<start-point>]`::
51
+
52
+ Create a new branch named _<new-branch>_, start it at _<start-point>_
53
+ (defaults to the current commit), and check out the new branch.
54
+ You can use the `--track` or `--no-track` options to set the branch's
55
+ upstream tracking information.
56
+
67
-that is to say, the branch is not reset/created unless "git checkout" is
68
-successful (e.g., when the branch is in use in another worktree, not
69
-just the current branch stays the same, but the branch is not reset to
70
-the start-point, either).
57
+This will fail if there's an error checking out _<new-branch>_, for
58
+example if checking out the `<start-point>` commit would overwrite your
59
+uncommitted changes.
60
+
61
+`git checkout -B <branch> [<start-point>]`::
62
+
63
+ The same as `-b`, except that if the branch already exists it
64
+ resets `_<branch>_` to the start point instead of failing.
65
66
`git checkout --detach [<branch>]`::
67
`git checkout [--detach] <commit>`::
151
see linkgit:git-branch[1] for details.
152
153
`-B <new-branch>`::
160
- Creates the branch _<new-branch>_, start it at _<start-point>_;
161
- if it already exists, then reset it to _<start-point>_. And then
162
- check the resulting branch out. This is equivalent to running
163
- `git branch` with `-f` followed by `git checkout` of that branch;
164
- see linkgit:git-branch[1] for details.
154
+ The same as `-b`, except that if the branch already exists it
155
+ resets `_<branch>_` to the start point instead of failing.
156
157
`-t`::
158
`--track[=(direct|inherit)]`::
159
When creating a new branch, set up "upstream" configuration. See
169
- `--track` in linkgit:git-branch[1] for details.
160
+ `--track` in linkgit:git-branch[1] for details. As a convenience,
161
+ --track without -b implies branch creation.
162
+
163
If no `-b` option is given, the name of the new branch will be
164
derived from the remote-tracking branch, by looking at the local part of