]> git.ipfire.org Git - thirdparty/git.git/blame - Documentation/git-checkout.txt
describe: allow more than one revs to be named.
[thirdparty/git.git] / Documentation / git-checkout.txt
CommitLineData
215a7ad1
JH
1git-checkout(1)
2===============
7fc9d69f
JH
3
4NAME
5----
215a7ad1 6git-checkout - Checkout and switch to a branch.
7fc9d69f
JH
7
8SYNOPSIS
9--------
4aaa7027 10'git-checkout' [-f] [-b <new_branch>] [<branch>] [<paths>...]
7fc9d69f
JH
11
12DESCRIPTION
13-----------
4aaa7027
JH
14
15When <paths> are not given, this command switches branches, by
16updating the index and working tree to reflect the specified
17branch, <branch>, and updating HEAD to be <branch> or, if
18specified, <new_branch>.
19
20When <paths> are given, this command does *not* switch
21branches. It updates the named paths in the working tree from
22the index file (i.e. it runs `git-checkout-index -f -u`). In
23this case, `-f` and `-b` options are meaningless and giving
24either of them results in an error. <branch> argument can be
25used to specify a specific tree-ish to update the index for the
26given paths before updating the working tree.
27
7fc9d69f
JH
28
29OPTIONS
30-------
0270f7c5
LAS
31-f::
32 Force an re-read of everything.
33
34-b::
35 Create a new branch and start it at <branch>.
7fc9d69f 36
0270f7c5
LAS
37<new_branch>::
38 Name for the new branch.
7fc9d69f 39
0270f7c5
LAS
40<branch>::
41 Branch to checkout; may be any object ID that resolves to a
42 commit. Defaults to HEAD.
7fc9d69f 43
4aaa7027
JH
44
45EXAMPLE
46-------
47
48The following sequence checks out the `master` branch, reverts
49the `Makefile` to two revisions back, deletes hello.c by
50mistake, and gets it back from the index.
51
52------------
1e2ccd3a
JH
53$ git checkout master <1>
54$ git checkout master~2 Makefile <2>
4aaa7027 55$ rm -f hello.c
1e2ccd3a
JH
56$ git checkout hello.c <3>
57
58<1> switch branch
59<2> take out a file out of other commit
60<3> or "git checkout -- hello.c", as in the next example.
4aaa7027
JH
61------------
62
63If you have an unfortunate branch that is named `hello.c`, the
64last step above would be confused as an instruction to switch to
65that branch. You should instead write:
66
67------------
68$ git checkout -- hello.c
69------------
70
71
7fc9d69f
JH
72Author
73------
74Written by Linus Torvalds <torvalds@osdl.org>
75
76Documentation
77--------------
78Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
79
80GIT
81---
a7154e91 82Part of the gitlink:git[7] suite
7fc9d69f 83