6 git-checkout - Abrufen (checkout) eines Entwicklungszweigs (branch) oder Pfad im Arbeitsbereich.
11 'git checkout' [-q] [-f] [[--track | --no-track] -b <new_branch> [-l]] [-m] [<branch>]
12 'git checkout' [<tree-ish>] [--] <paths>...
17 Wenn <paths> nicht angegeben werden, dann wechselt dieser Befehl den
18 aktiven Entwicklungszweig (branch) durch Aktualisierung des Index und des
19 Arbeitsbereichs. Weiters wird HEAD auf <branch> (oder wenn angegeben
20 <newbranch>) gelegt. Verwendet man die '-b' Option wird ein neuer
21 Entwicklungszweig angelegt, wobei dann die Optionen '--track' bzw
22 '--no-track' angegeben werden können, die an den 'git branch' Befehl
25 Werden <paths> angegeben, dann wird der aktive Entwicklungszweig (branch)
26 *nicht* gewechselt, sondern die benannten Dateipfade im Arbeitsbereich
27 werden aus dem Index (durch Ausführen von `git checkout-index -f -u`),
28 oder aus einer benannten Eintragung (commit) aktualisiert. In diesem Fall
29 sind die Optionen '-f' und '-b' unzulässig und führen bei der Verwendung
30 zu einer Fehlermeldung. <tree-ish> argument can be
31 used to specify a specific tree-ish (i.e. commit, tag or tree)
32 to update the index for the given paths before updating the
39 Leise, unterdrücke Hinweisnachrichten.
42 Erzwinge die Durchführung, selbst dann wenn der Arbeitsbereich
43 (working tree) sich vom HEAD unterscheidet. Dies wird verwendet
44 um lokale Änderungen wegzuwerfen.
47 Create a new branch named <new_branch> and start it at
48 <branch>. The new branch name must pass all checks defined
49 by linkgit:git-check-ref-format[1]. Some of these checks
50 may restrict the characters allowed in a branch name.
54 When creating a new branch, set up configuration so that 'git-pull'
55 will automatically retrieve data from the start point, which must be
56 a branch. Use this if you always pull from the same upstream branch
57 into the new branch, and if you don't want to use "git pull
58 <repository> <refspec>" explicitly. This behavior is the default
59 when the start point is a remote branch. Set the
60 branch.autosetupmerge configuration variable to `false` if you want
61 'git-checkout' and 'git-branch' to always behave as if '--no-track' were
62 given. Set it to `always` if you want this behavior when the
63 start-point is either a local or remote branch.
66 Ignore the branch.autosetupmerge configuration variable.
69 Create the new branch's reflog. This activates recording of
70 all changes made to the branch ref, enabling use of date
71 based sha1 expressions such as "<branchname>@\{yesterday}".
74 If you have local modifications to one or more files that
75 are different between the current branch and the branch to
76 which you are switching, the command refuses to switch
77 branches in order to preserve your modifications in context.
78 However, with this option, a three-way merge between the current
79 branch, your working tree contents, and the new branch
80 is done, and you will be on the new branch.
82 When a merge conflict happens, the index entries for conflicting
83 paths are left unmerged, and you need to resolve the conflicts
84 and mark the resolved paths with `git add` (or `git rm` if the merge
85 should result in deletion of the path).
88 Name for the new branch.
91 Branch to checkout; may be any object ID that resolves to a
92 commit. Defaults to HEAD.
94 When this parameter names a non-branch (but still a valid commit object),
95 your HEAD becomes 'detached'.
101 It is sometimes useful to be able to 'checkout' a commit that is
102 not at the tip of one of your branches. The most obvious
103 example is to check out the commit at a tagged official release
107 $ git checkout v2.6.18
110 Earlier versions of git did not allow this and asked you to
111 create a temporary branch using `-b` option, but starting from
112 version 1.5.0, the above command 'detaches' your HEAD from the
113 current branch and directly point at the commit named by the tag
114 (`v2.6.18` in the above example).
116 You can use usual git commands while in this state. You can use
117 `git reset --hard $othercommit` to further move around, for
118 example. You can make changes and create a new commit on top of
119 a detached HEAD. You can even create a merge by using `git
122 The state you are in while your HEAD is detached is not recorded
123 by any branch (which is natural --- you are not on any branch).
124 What this means is that you can discard your temporary commits
125 and merges by switching back to an existing branch (e.g. `git
126 checkout master`), and a later `git prune` or `git gc` would
127 garbage-collect them. If you did this by mistake, you can ask
128 the reflog for HEAD where you were, e.g.
138 . The following sequence checks out the `master` branch, reverts
139 the `Makefile` to two revisions back, deletes hello.c by
140 mistake, and gets it back from the index.
143 $ git checkout master <1>
144 $ git checkout master~2 Makefile <2>
146 $ git checkout hello.c <3>
150 <2> take out a file out of other commit
151 <3> restore hello.c from HEAD of current branch
153 If you have an unfortunate branch that is named `hello.c`, this
154 step would be confused as an instruction to switch to that branch.
155 You should instead write:
158 $ git checkout -- hello.c
161 . After working in a wrong branch, switching to the correct
162 branch would be done using:
165 $ git checkout mytopic
168 However, your "wrong" branch and correct "mytopic" branch may
169 differ in files that you have locally modified, in which case,
170 the above checkout would fail like this:
173 $ git checkout mytopic
174 fatal: Entry 'frotz' not uptodate. Cannot merge.
177 You can give the `-m` flag to the command, which would try a
181 $ git checkout -m mytopic
185 After this three-way merge, the local modifications are _not_
186 registered in your index file, so `git diff` would show you what
187 changes you made since the tip of the new branch.
189 . When a merge conflict happens during switching branches with
190 the `-m` option, you would see something like this:
193 $ git checkout -m mytopic
195 merge: warning: conflicts during merge
196 ERROR: Merge conflict in frotz
197 fatal: merge program failed
200 At this point, `git diff` shows the changes cleanly merged as in
201 the previous example, as well as the changes in the conflicted
202 files. Edit and resolve the conflict and mark it resolved with
213 Written by Linus Torvalds <torvalds@osdl.org>
217 Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.
221 Part of the linkgit:git[1] suite