..
.TH "GIT-CHECKOUT" 1 "" "" ""
.SH NAME
-git-checkout \- Checkout and switch to a branch.
+git-checkout \- Checkout and switch to a branch
.SH "SYNOPSIS"
-git\-checkout [\-f] [\-b <new_branch>] [\-m] [<branch>] [<paths>...]
+\fIgit\-checkout\fR [\-f] [\-b <new_branch>] [\-m] [<branch>] [<paths>...]
.SH "DESCRIPTION"
When <paths> are not given, this command switches branches, by updating the index and working tree to reflect the specified branch, <branch>, and updating HEAD to be <branch> or, if specified, <new_branch>\&.
-When <paths> are given, this command does not switch branches\&. It updates the named paths in the working tree from the index file (i\&.e\&. it runs git\-checkout\-index \-f \-u)\&. In this case, \-f and \-b options are meaningless and giving either of them results in an error\&. <branch> argument can be used to specify a specific tree\-ish to update the index for the given paths before updating the working tree\&.
+When <paths> are given, this command does \fInot\fR switch branches\&. It updates the named paths in the working tree from the index file (i\&.e\&. it runs git\-checkout\-index \-f \-u)\&. In this case, \-f and \-b options are meaningless and giving either of them results in an error\&. <branch> argument can be used to specify a specific tree\-ish to update the index for the given paths before updating the working tree\&.
.SH "OPTIONS"
The following sequence checks out the master branch, reverts the Makefile to two revisions back, deletes hello\&.c by mistake, and gets it back from the index\&.
-.IP
+.nf
$ git checkout master
$ git checkout master~2 Makefile
$ rm \-f hello\&.c
switch branch
take out a file out of other commit
- or "git checkout \-\- hello\&.c", as in the next example\&.If you have an unfortunate branch that is named hello\&.c, the last step above would be confused as an instruction to switch to that branch\&. You should instead write:
+ or "git checkout \-\- hello\&.c", as in the next example\&.
+.fi
+If you have an unfortunate branch that is named hello\&.c, the last step above would be confused as an instruction to switch to that branch\&. You should instead write:
-.IP
-$ git checkout \-\- hello\&.c.TP
+.nf
+$ git checkout \-\- hello\&.c
+.fi
+.TP
2.
After working in a wrong branch, switching to the correct branch you would want to is done with:
-.IP
-$ git checkout mytopicHowever, your "wrong" branch and correct "mytopic" branch may differ in files that you have locally modified, in which case, the above checkout would fail like this:
+.nf
+$ git checkout mytopic
+.fi
+However, your "wrong" branch and correct "mytopic" branch may differ in files that you have locally modified, in which case, the above checkout would fail like this:
-.IP
+.nf
$ git checkout mytopic
-fatal: Entry 'frotz' not uptodate\&. Cannot merge\&.You can give the \-m flag to the command, which would try a three\-way merge:
+fatal: Entry 'frotz' not uptodate\&. Cannot merge\&.
+.fi
+You can give the \-m flag to the command, which would try a three\-way merge:
-.IP
+.nf
$ git checkout \-m mytopic
-Auto\-merging frotzAfter this three\-way merge, the local modifications are _not_ registered in your index file, so git diff would show you what changes you made since the tip of the new branch\&.
+Auto\-merging frotz
+.fi
+After this three\-way merge, the local modifications are _not_ registered in your index file, so git diff would show you what changes you made since the tip of the new branch\&.
.TP
3.
When a merge conflict happens during switching branches with the \-m option, you would see something like this:
-.IP
+.nf
$ git checkout \-m mytopic
Auto\-merging frotz
merge: warning: conflicts during merge
ERROR: Merge conflict in frotz
-fatal: merge program failedAt this point, git diff shows the changes cleanly merged as in the previous example, as well as the changes in the conflicted files\&. Edit and resolve the conflict and mark it resolved with git update\-index as usual:
+fatal: merge program failed
+.fi
+At this point, git diff shows the changes cleanly merged as in the previous example, as well as the changes in the conflicted files\&. Edit and resolve the conflict and mark it resolved with git update\-index as usual:
-.IP
+.nf
$ edit frotz
-$ git update\-index frotz.LP
+$ git update\-index frotz
+.fi
+.LP
.SH "AUTHOR"