| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" | 
|  | 2 | "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> | 
|  | 3 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> | 
|  | 4 | <head> | 
|  | 5 | <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 6 | <meta name="generator" content="AsciiDoc 8.2.5" /> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 7 | <style type="text/css"> | 
|  | 8 | /* Debug borders */ | 
|  | 9 | p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 { | 
|  | 10 | /* | 
|  | 11 | border: 1px solid red; | 
|  | 12 | */ | 
|  | 13 | } | 
|  | 14 |  | 
|  | 15 | body { | 
|  | 16 | margin: 1em 5% 1em 5%; | 
|  | 17 | } | 
|  | 18 |  | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 19 | a { | 
|  | 20 | color: blue; | 
|  | 21 | text-decoration: underline; | 
|  | 22 | } | 
|  | 23 | a:visited { | 
|  | 24 | color: fuchsia; | 
|  | 25 | } | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 26 |  | 
|  | 27 | em { | 
|  | 28 | font-style: italic; | 
|  | 29 | } | 
|  | 30 |  | 
|  | 31 | strong { | 
|  | 32 | font-weight: bold; | 
|  | 33 | } | 
|  | 34 |  | 
|  | 35 | tt { | 
|  | 36 | color: navy; | 
|  | 37 | } | 
|  | 38 |  | 
|  | 39 | h1, h2, h3, h4, h5, h6 { | 
|  | 40 | color: #527bbd; | 
|  | 41 | font-family: sans-serif; | 
|  | 42 | margin-top: 1.2em; | 
|  | 43 | margin-bottom: 0.5em; | 
|  | 44 | line-height: 1.3; | 
|  | 45 | } | 
|  | 46 |  | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 47 | h1, h2, h3 { | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 48 | border-bottom: 2px solid silver; | 
|  | 49 | } | 
|  | 50 | h2 { | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 51 | padding-top: 0.5em; | 
|  | 52 | } | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 53 | h3 { | 
|  | 54 | float: left; | 
|  | 55 | } | 
|  | 56 | h3 + * { | 
|  | 57 | clear: left; | 
|  | 58 | } | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 59 |  | 
|  | 60 | div.sectionbody { | 
|  | 61 | font-family: serif; | 
|  | 62 | margin-left: 0; | 
|  | 63 | } | 
|  | 64 |  | 
|  | 65 | hr { | 
|  | 66 | border: 1px solid silver; | 
|  | 67 | } | 
|  | 68 |  | 
|  | 69 | p { | 
|  | 70 | margin-top: 0.5em; | 
|  | 71 | margin-bottom: 0.5em; | 
|  | 72 | } | 
|  | 73 |  | 
|  | 74 | pre { | 
|  | 75 | padding: 0; | 
|  | 76 | margin: 0; | 
|  | 77 | } | 
|  | 78 |  | 
|  | 79 | span#author { | 
|  | 80 | color: #527bbd; | 
|  | 81 | font-family: sans-serif; | 
|  | 82 | font-weight: bold; | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 83 | font-size: 1.1em; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 84 | } | 
|  | 85 | span#email { | 
|  | 86 | } | 
|  | 87 | span#revision { | 
|  | 88 | font-family: sans-serif; | 
|  | 89 | } | 
|  | 90 |  | 
|  | 91 | div#footer { | 
|  | 92 | font-family: sans-serif; | 
|  | 93 | font-size: small; | 
|  | 94 | border-top: 2px solid silver; | 
|  | 95 | padding-top: 0.5em; | 
|  | 96 | margin-top: 4.0em; | 
|  | 97 | } | 
|  | 98 | div#footer-text { | 
|  | 99 | float: left; | 
|  | 100 | padding-bottom: 0.5em; | 
|  | 101 | } | 
|  | 102 | div#footer-badges { | 
|  | 103 | float: right; | 
|  | 104 | padding-bottom: 0.5em; | 
|  | 105 | } | 
|  | 106 |  | 
|  | 107 | div#preamble, | 
|  | 108 | div.tableblock, div.imageblock, div.exampleblock, div.verseblock, | 
|  | 109 | div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, | 
|  | 110 | div.admonitionblock { | 
|  | 111 | margin-right: 10%; | 
|  | 112 | margin-top: 1.5em; | 
|  | 113 | margin-bottom: 1.5em; | 
|  | 114 | } | 
|  | 115 | div.admonitionblock { | 
|  | 116 | margin-top: 2.5em; | 
|  | 117 | margin-bottom: 2.5em; | 
|  | 118 | } | 
|  | 119 |  | 
|  | 120 | div.content { /* Block element content. */ | 
|  | 121 | padding: 0; | 
|  | 122 | } | 
|  | 123 |  | 
|  | 124 | /* Block element titles. */ | 
|  | 125 | div.title, caption.title { | 
|  | 126 | font-family: sans-serif; | 
|  | 127 | font-weight: bold; | 
|  | 128 | text-align: left; | 
|  | 129 | margin-top: 1.0em; | 
|  | 130 | margin-bottom: 0.5em; | 
|  | 131 | } | 
|  | 132 | div.title + * { | 
|  | 133 | margin-top: 0; | 
|  | 134 | } | 
|  | 135 |  | 
|  | 136 | td div.title:first-child { | 
|  | 137 | margin-top: 0.0em; | 
|  | 138 | } | 
|  | 139 | div.content div.title:first-child { | 
|  | 140 | margin-top: 0.0em; | 
|  | 141 | } | 
|  | 142 | div.content + div.title { | 
|  | 143 | margin-top: 0.0em; | 
|  | 144 | } | 
|  | 145 |  | 
|  | 146 | div.sidebarblock > div.content { | 
|  | 147 | background: #ffffee; | 
|  | 148 | border: 1px solid silver; | 
|  | 149 | padding: 0.5em; | 
|  | 150 | } | 
|  | 151 |  | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 152 | div.listingblock { | 
|  | 153 | margin-right: 0%; | 
|  | 154 | } | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 155 | div.listingblock > div.content { | 
|  | 156 | border: 1px solid silver; | 
|  | 157 | background: #f4f4f4; | 
|  | 158 | padding: 0.5em; | 
|  | 159 | } | 
|  | 160 |  | 
|  | 161 | div.quoteblock > div.content { | 
|  | 162 | padding-left: 2.0em; | 
|  | 163 | } | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 164 |  | 
|  | 165 | div.attribution { | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 166 | text-align: right; | 
|  | 167 | } | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 168 | div.verseblock + div.attribution { | 
|  | 169 | text-align: left; | 
|  | 170 | } | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 171 |  | 
|  | 172 | div.admonitionblock .icon { | 
|  | 173 | vertical-align: top; | 
|  | 174 | font-size: 1.1em; | 
|  | 175 | font-weight: bold; | 
|  | 176 | text-decoration: underline; | 
|  | 177 | color: #527bbd; | 
|  | 178 | padding-right: 0.5em; | 
|  | 179 | } | 
|  | 180 | div.admonitionblock td.content { | 
|  | 181 | padding-left: 0.5em; | 
|  | 182 | border-left: 2px solid silver; | 
|  | 183 | } | 
|  | 184 |  | 
|  | 185 | div.exampleblock > div.content { | 
|  | 186 | border-left: 2px solid silver; | 
|  | 187 | padding: 0.5em; | 
|  | 188 | } | 
|  | 189 |  | 
|  | 190 | div.verseblock div.content { | 
|  | 191 | white-space: pre; | 
|  | 192 | } | 
|  | 193 |  | 
|  | 194 | div.imageblock div.content { padding-left: 0; } | 
|  | 195 | div.imageblock img { border: 1px solid silver; } | 
|  | 196 | span.image img { border-style: none; } | 
|  | 197 |  | 
|  | 198 | dl { | 
|  | 199 | margin-top: 0.8em; | 
|  | 200 | margin-bottom: 0.8em; | 
|  | 201 | } | 
|  | 202 | dt { | 
|  | 203 | margin-top: 0.5em; | 
|  | 204 | margin-bottom: 0; | 
|  | 205 | font-style: italic; | 
|  | 206 | } | 
|  | 207 | dd > *:first-child { | 
|  | 208 | margin-top: 0; | 
|  | 209 | } | 
|  | 210 |  | 
|  | 211 | ul, ol { | 
|  | 212 | list-style-position: outside; | 
|  | 213 | } | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 214 | div.olist2 ol { | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 215 | list-style-type: lower-alpha; | 
|  | 216 | } | 
|  | 217 |  | 
|  | 218 | div.tableblock > table { | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 219 | border: 3px solid #527bbd; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 220 | } | 
|  | 221 | thead { | 
|  | 222 | font-family: sans-serif; | 
|  | 223 | font-weight: bold; | 
|  | 224 | } | 
|  | 225 | tfoot { | 
|  | 226 | font-weight: bold; | 
|  | 227 | } | 
|  | 228 |  | 
|  | 229 | div.hlist { | 
|  | 230 | margin-top: 0.8em; | 
|  | 231 | margin-bottom: 0.8em; | 
|  | 232 | } | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 233 | div.hlist td { | 
|  | 234 | padding-bottom: 5px; | 
|  | 235 | } | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 236 | td.hlist1 { | 
|  | 237 | vertical-align: top; | 
|  | 238 | font-style: italic; | 
|  | 239 | padding-right: 0.8em; | 
|  | 240 | } | 
|  | 241 | td.hlist2 { | 
|  | 242 | vertical-align: top; | 
|  | 243 | } | 
|  | 244 |  | 
|  | 245 | @media print { | 
|  | 246 | div#footer-badges { display: none; } | 
|  | 247 | } | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 248 |  | 
|  | 249 | div#toctitle { | 
|  | 250 | color: #527bbd; | 
|  | 251 | font-family: sans-serif; | 
|  | 252 | font-size: 1.1em; | 
|  | 253 | font-weight: bold; | 
|  | 254 | margin-top: 1.0em; | 
|  | 255 | margin-bottom: 0.1em; | 
|  | 256 | } | 
|  | 257 |  | 
|  | 258 | div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { | 
|  | 259 | margin-top: 0; | 
|  | 260 | margin-bottom: 0; | 
|  | 261 | } | 
|  | 262 | div.toclevel2 { | 
|  | 263 | margin-left: 2em; | 
|  | 264 | font-size: 0.9em; | 
|  | 265 | } | 
|  | 266 | div.toclevel3 { | 
|  | 267 | margin-left: 4em; | 
|  | 268 | font-size: 0.9em; | 
|  | 269 | } | 
|  | 270 | div.toclevel4 { | 
|  | 271 | margin-left: 6em; | 
|  | 272 | font-size: 0.9em; | 
|  | 273 | } | 
|  | 274 | include1::./stylesheets/xhtml11-manpage.css[] | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 275 | /* Workarounds for IE6's broken and incomplete CSS2. */ | 
|  | 276 |  | 
|  | 277 | div.sidebar-content { | 
|  | 278 | background: #ffffee; | 
|  | 279 | border: 1px solid silver; | 
|  | 280 | padding: 0.5em; | 
|  | 281 | } | 
|  | 282 | div.sidebar-title, div.image-title { | 
|  | 283 | font-family: sans-serif; | 
|  | 284 | font-weight: bold; | 
|  | 285 | margin-top: 0.0em; | 
|  | 286 | margin-bottom: 0.5em; | 
|  | 287 | } | 
|  | 288 |  | 
|  | 289 | div.listingblock div.content { | 
|  | 290 | border: 1px solid silver; | 
|  | 291 | background: #f4f4f4; | 
|  | 292 | padding: 0.5em; | 
|  | 293 | } | 
|  | 294 |  | 
|  | 295 | div.quoteblock-content { | 
|  | 296 | padding-left: 2.0em; | 
|  | 297 | } | 
|  | 298 |  | 
|  | 299 | div.exampleblock-content { | 
|  | 300 | border-left: 2px solid silver; | 
|  | 301 | padding-left: 0.5em; | 
|  | 302 | } | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 303 |  | 
|  | 304 | /* IE6 sets dynamically generated links as visited. */ | 
|  | 305 | div#toc a:visited { color: blue; } | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 306 | </style> | 
|  | 307 | <title>git-checkout(1)</title> | 
|  | 308 | </head> | 
|  | 309 | <body> | 
|  | 310 | <div id="header"> | 
|  | 311 | <h1> | 
|  | 312 | git-checkout(1) Manual Page | 
|  | 313 | </h1> | 
|  | 314 | <h2>NAME</h2> | 
|  | 315 | <div class="sectionbody"> | 
|  | 316 | <p>git-checkout - | 
| Junio C Hamano | a14a403 | 2008-03-25 09:11:02 | [diff] [blame] | 317 | Checkout a branch or paths to the working tree | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 318 | </p> | 
|  | 319 | </div> | 
|  | 320 | </div> | 
|  | 321 | <h2>SYNOPSIS</h2> | 
|  | 322 | <div class="sectionbody"> | 
| Junio C Hamano | 2b13527 | 2006-03-18 07:45:42 | [diff] [blame] | 323 | <div class="verseblock"> | 
| Junio C Hamano | 5cf43ca | 2008-08-20 09:14:14 | [diff] [blame] | 324 | <div class="content"><em>git checkout</em> [-q] [-f] [--track | --no-track] [-b <new_branch> [-l]] [-m] [<branch>] | 
| Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame^] | 325 | <em>git checkout</em> [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>…</div></div> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 326 | </div> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 327 | <h2 id="_description">DESCRIPTION</h2> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 328 | <div class="sectionbody"> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 329 | <div class="para"><p>When <paths> are not given, this command switches branches by | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 330 | updating the index and working tree to reflect the specified | 
|  | 331 | branch, <branch>, and updating HEAD to be <branch> or, if | 
| Junio C Hamano | 2b13527 | 2006-03-18 07:45:42 | [diff] [blame] | 332 | specified, <new_branch>. Using -b will cause <new_branch> to | 
| Junio C Hamano | 103ad7f | 2007-03-14 11:19:26 | [diff] [blame] | 333 | be created; in this case you can use the --track or --no-track | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 334 | options, which will be passed to <tt>git branch</tt>.</p></div> | 
| Junio C Hamano | 5cf43ca | 2008-08-20 09:14:14 | [diff] [blame] | 335 | <div class="para"><p>As a convenience, --track will default to create a branch whose | 
|  | 336 | name is constructed from the specified branch name by stripping | 
|  | 337 | the first namespace level.</p></div> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 338 | <div class="para"><p>When <paths> are given, this command does <strong>not</strong> switch | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 339 | branches. It updates the named paths in the working tree from | 
| Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame^] | 340 | the index file, or from a named commit. In | 
|  | 341 | this case, the <tt>-b</tt> options is meaningless and giving | 
| Junio C Hamano | 8f62db9 | 2007-02-01 00:22:22 | [diff] [blame] | 342 | either of them results in an error. <tree-ish> argument can be | 
|  | 343 | used to specify a specific tree-ish (i.e. commit, tag or tree) | 
|  | 344 | to update the index for the given paths before updating the | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 345 | working tree.</p></div> | 
| Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame^] | 346 | <div class="para"><p>The index may contain unmerged entries after a failed merge. By | 
|  | 347 | default, if you try to check out such an entry from the index, the | 
|  | 348 | checkout operation will fail and nothing will be checked out. | 
|  | 349 | Using -f will ignore these unmerged entries. The contents from a | 
|  | 350 | specific side of the merge can be checked out of the index by | 
|  | 351 | using --ours or --theirs. With -m, changes made to the working tree | 
|  | 352 | file can be discarded to recreate the original conflicted merge result.</p></div> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 353 | </div> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 354 | <h2 id="_options">OPTIONS</h2> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 355 | <div class="sectionbody"> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 356 | <div class="vlist"><dl> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 357 | <dt> | 
| Junio C Hamano | 39381a7 | 2007-02-02 07:35:15 | [diff] [blame] | 358 | -q | 
|  | 359 | </dt> | 
|  | 360 | <dd> | 
|  | 361 | <p> | 
| Junio C Hamano | cae8627 | 2007-08-21 02:20:49 | [diff] [blame] | 362 | Quiet, suppress feedback messages. | 
| Junio C Hamano | 39381a7 | 2007-02-02 07:35:15 | [diff] [blame] | 363 | </p> | 
|  | 364 | </dd> | 
|  | 365 | <dt> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 366 | -f | 
|  | 367 | </dt> | 
|  | 368 | <dd> | 
|  | 369 | <p> | 
| Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame^] | 370 | When switching branches, proceed even if the index or the | 
|  | 371 | working tree differs from HEAD. This is used to throw away | 
|  | 372 | local changes. | 
|  | 373 | </p> | 
|  | 374 | <div class="para"><p>When checking out paths from the index, do not fail upon unmerged | 
|  | 375 | entries; instead, unmerged entries are ignored.</p></div> | 
|  | 376 | </dd> | 
|  | 377 | <dt> | 
|  | 378 | --ours | 
|  | 379 | </dt> | 
|  | 380 | <dt> | 
|  | 381 | --theirs | 
|  | 382 | </dt> | 
|  | 383 | <dd> | 
|  | 384 | <p> | 
|  | 385 | When checking out paths from the index, check out stage #2 | 
|  | 386 | (<em>ours</em>) or #3 (<em>theirs</em>) for unmerged paths. | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 387 | </p> | 
|  | 388 | </dd> | 
|  | 389 | <dt> | 
|  | 390 | -b | 
|  | 391 | </dt> | 
|  | 392 | <dd> | 
|  | 393 | <p> | 
| Junio C Hamano | b2f5edd | 2006-05-21 10:50:09 | [diff] [blame] | 394 | Create a new branch named <new_branch> and start it at | 
|  | 395 | <branch>. The new branch name must pass all checks defined | 
|  | 396 | by <a href="git-check-ref-format.html">git-check-ref-format(1)</a>. Some of these checks | 
|  | 397 | may restrict the characters allowed in a branch name. | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 398 | </p> | 
|  | 399 | </dd> | 
|  | 400 | <dt> | 
| Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 401 | -t | 
|  | 402 | </dt> | 
|  | 403 | <dt> | 
|  | 404 | --track | 
| Junio C Hamano | 103ad7f | 2007-03-14 11:19:26 | [diff] [blame] | 405 | </dt> | 
|  | 406 | <dd> | 
|  | 407 | <p> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 408 | When creating a new branch, set up configuration so that <em>git-pull</em> | 
| Junio C Hamano | 24bc09a | 2008-02-28 00:27:44 | [diff] [blame] | 409 | will automatically retrieve data from the start point, which must be | 
|  | 410 | a branch. Use this if you always pull from the same upstream branch | 
|  | 411 | into the new branch, and if you don't want to use "git pull | 
|  | 412 | <repository> <refspec>" explicitly. This behavior is the default | 
|  | 413 | when the start point is a remote branch. Set the | 
|  | 414 | branch.autosetupmerge configuration variable to <tt>false</tt> if you want | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 415 | <em>git-checkout</em> and <em>git-branch</em> to always behave as if <em>--no-track</em> were | 
| Junio C Hamano | 24bc09a | 2008-02-28 00:27:44 | [diff] [blame] | 416 | given. Set it to <tt>always</tt> if you want this behavior when the | 
|  | 417 | start-point is either a local or remote branch. | 
| Junio C Hamano | 103ad7f | 2007-03-14 11:19:26 | [diff] [blame] | 418 | </p> | 
| Junio C Hamano | 043628e | 2008-08-24 03:34:11 | [diff] [blame] | 419 | <div class="para"><p>If no <em>-b</em> option was given, the name of the new branch will be | 
|  | 420 | derived from the remote branch, by attempting to guess the name | 
|  | 421 | of the branch on remote system. If "remotes/" or "refs/remotes/" | 
|  | 422 | are prefixed, it is stripped away, and then the part up to the | 
|  | 423 | next slash (which would be the nickname of the remote) is removed. | 
|  | 424 | This would tell us to use "hack" as the local branch when branching | 
|  | 425 | off of "origin/hack" (or "remotes/origin/hack", or even | 
|  | 426 | "refs/remotes/origin/hack"). If the given name has no slash, or the above | 
|  | 427 | guessing results in an empty name, the guessing is aborted. You can | 
|  | 428 | exlicitly give a name with <em>-b</em> in such a case.</p></div> | 
| Junio C Hamano | 103ad7f | 2007-03-14 11:19:26 | [diff] [blame] | 429 | </dd> | 
|  | 430 | <dt> | 
|  | 431 | --no-track | 
|  | 432 | </dt> | 
|  | 433 | <dd> | 
|  | 434 | <p> | 
| Junio C Hamano | 24bc09a | 2008-02-28 00:27:44 | [diff] [blame] | 435 | Ignore the branch.autosetupmerge configuration variable. | 
| Junio C Hamano | 103ad7f | 2007-03-14 11:19:26 | [diff] [blame] | 436 | </p> | 
|  | 437 | </dd> | 
|  | 438 | <dt> | 
| Junio C Hamano | 341071d | 2006-06-04 07:24:48 | [diff] [blame] | 439 | -l | 
|  | 440 | </dt> | 
|  | 441 | <dd> | 
|  | 442 | <p> | 
| Junio C Hamano | 1d90cb0 | 2007-07-03 07:05:31 | [diff] [blame] | 443 | Create the new branch's reflog. This activates recording of | 
|  | 444 | all changes made to the branch ref, enabling use of date | 
|  | 445 | based sha1 expressions such as "<branchname>@{yesterday}". | 
| Junio C Hamano | 341071d | 2006-06-04 07:24:48 | [diff] [blame] | 446 | </p> | 
|  | 447 | </dd> | 
|  | 448 | <dt> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 449 | -m | 
|  | 450 | </dt> | 
| Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame^] | 451 | <dt> | 
|  | 452 | --merge | 
|  | 453 | </dt> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 454 | <dd> | 
|  | 455 | <p> | 
| Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame^] | 456 | When switching branches, | 
|  | 457 | if you have local modifications to one or more files that | 
| Junio C Hamano | 2b13527 | 2006-03-18 07:45:42 | [diff] [blame] | 458 | are different between the current branch and the branch to | 
|  | 459 | which you are switching, the command refuses to switch | 
|  | 460 | branches in order to preserve your modifications in context. | 
|  | 461 | However, with this option, a three-way merge between the current | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 462 | branch, your working tree contents, and the new branch | 
|  | 463 | is done, and you will be on the new branch. | 
|  | 464 | </p> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 465 | <div class="para"><p>When a merge conflict happens, the index entries for conflicting | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 466 | paths are left unmerged, and you need to resolve the conflicts | 
| Junio C Hamano | 89d4e0f | 2007-02-18 00:34:59 | [diff] [blame] | 467 | and mark the resolved paths with <tt>git add</tt> (or <tt>git rm</tt> if the merge | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 468 | should result in deletion of the path).</p></div> | 
| Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame^] | 469 | <div class="para"><p>When checking out paths from the index, this option lets you recreate | 
|  | 470 | the conflicted merge in the specified paths.</p></div> | 
|  | 471 | </dd> | 
|  | 472 | <dt> | 
|  | 473 | --conflict=<style> | 
|  | 474 | </dt> | 
|  | 475 | <dd> | 
|  | 476 | <p> | 
|  | 477 | The same as --merge option above, but changes the way the | 
|  | 478 | conflicting hunks are presented, overriding the | 
|  | 479 | merge.conflictstyle configuration variable. Possible values are | 
|  | 480 | "merge" (default) and "diff3" (in addition to what is shown by | 
|  | 481 | "merge" style, shows the original contents). | 
|  | 482 | </p> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 483 | </dd> | 
|  | 484 | <dt> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 485 | <new_branch> | 
|  | 486 | </dt> | 
|  | 487 | <dd> | 
|  | 488 | <p> | 
|  | 489 | Name for the new branch. | 
|  | 490 | </p> | 
|  | 491 | </dd> | 
|  | 492 | <dt> | 
|  | 493 | <branch> | 
|  | 494 | </dt> | 
|  | 495 | <dd> | 
|  | 496 | <p> | 
|  | 497 | Branch to checkout; may be any object ID that resolves to a | 
| Junio C Hamano | 4f9a605 | 2007-01-17 20:25:16 | [diff] [blame] | 498 | commit. Defaults to HEAD. | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 499 | </p> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 500 | <div class="para"><p>When this parameter names a non-branch (but still a valid commit object), | 
|  | 501 | your HEAD becomes <em>detached</em>.</p></div> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 502 | </dd> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 503 | </dl></div> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 504 | </div> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 505 | <h2 id="_detached_head">Detached HEAD</h2> | 
| Junio C Hamano | 4f9a605 | 2007-01-17 20:25:16 | [diff] [blame] | 506 | <div class="sectionbody"> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 507 | <div class="para"><p>It is sometimes useful to be able to <em>checkout</em> a commit that is | 
| Junio C Hamano | 4f9a605 | 2007-01-17 20:25:16 | [diff] [blame] | 508 | not at the tip of one of your branches. The most obvious | 
|  | 509 | example is to check out the commit at a tagged official release | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 510 | point, like this:</p></div> | 
| Junio C Hamano | 4f9a605 | 2007-01-17 20:25:16 | [diff] [blame] | 511 | <div class="listingblock"> | 
|  | 512 | <div class="content"> | 
|  | 513 | <pre><tt>$ git checkout v2.6.18</tt></pre> | 
|  | 514 | </div></div> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 515 | <div class="para"><p>Earlier versions of git did not allow this and asked you to | 
| Junio C Hamano | 4f9a605 | 2007-01-17 20:25:16 | [diff] [blame] | 516 | create a temporary branch using <tt>-b</tt> option, but starting from | 
|  | 517 | version 1.5.0, the above command <em>detaches</em> your HEAD from the | 
|  | 518 | current branch and directly point at the commit named by the tag | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 519 | (<tt>v2.6.18</tt> in the above example).</p></div> | 
|  | 520 | <div class="para"><p>You can use usual git commands while in this state. You can use | 
| Junio C Hamano | fce7c7e | 2008-07-02 03:06:38 | [diff] [blame] | 521 | <tt>git reset --hard $othercommit</tt> to further move around, for | 
| Junio C Hamano | 4f9a605 | 2007-01-17 20:25:16 | [diff] [blame] | 522 | example. You can make changes and create a new commit on top of | 
|  | 523 | a detached HEAD. You can even create a merge by using <tt>git | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 524 | merge $othercommit</tt>.</p></div> | 
|  | 525 | <div class="para"><p>The state you are in while your HEAD is detached is not recorded | 
| Junio C Hamano | 4f9a605 | 2007-01-17 20:25:16 | [diff] [blame] | 526 | by any branch (which is natural --- you are not on any branch). | 
|  | 527 | What this means is that you can discard your temporary commits | 
|  | 528 | and merges by switching back to an existing branch (e.g. <tt>git | 
|  | 529 | checkout master</tt>), and a later <tt>git prune</tt> or <tt>git gc</tt> would | 
| Junio C Hamano | 9d52e57 | 2007-02-13 23:48:20 | [diff] [blame] | 530 | garbage-collect them. If you did this by mistake, you can ask | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 531 | the reflog for HEAD where you were, e.g.</p></div> | 
| Junio C Hamano | 9d52e57 | 2007-02-13 23:48:20 | [diff] [blame] | 532 | <div class="listingblock"> | 
|  | 533 | <div class="content"> | 
|  | 534 | <pre><tt>$ git log -g -2 HEAD</tt></pre> | 
|  | 535 | </div></div> | 
| Junio C Hamano | 4f9a605 | 2007-01-17 20:25:16 | [diff] [blame] | 536 | </div> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 537 | <h2 id="_examples">EXAMPLES</h2> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 538 | <div class="sectionbody"> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 539 | <div class="olist"><ol> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 540 | <li> | 
|  | 541 | <p> | 
|  | 542 | The following sequence checks out the <tt>master</tt> branch, reverts | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 543 | the <tt>Makefile</tt> to two revisions back, deletes hello.c by | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 544 | mistake, and gets it back from the index. | 
|  | 545 | </p> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 546 | <div class="listingblock"> | 
|  | 547 | <div class="content"> | 
| Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 548 | <pre><tt>$ git checkout master <b>(1)</b> | 
|  | 549 | $ git checkout master~2 Makefile <b>(2)</b> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 550 | $ rm -f hello.c | 
| Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 551 | $ git checkout hello.c <b>(3)</b></tt></pre> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 552 | </div></div> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 553 | <div class="colist"><ol> | 
| Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 554 | <li> | 
|  | 555 | <p> | 
|  | 556 | switch branch | 
|  | 557 | </p> | 
|  | 558 | </li> | 
|  | 559 | <li> | 
|  | 560 | <p> | 
|  | 561 | take out a file out of other commit | 
|  | 562 | </p> | 
|  | 563 | </li> | 
|  | 564 | <li> | 
|  | 565 | <p> | 
|  | 566 | restore hello.c from HEAD of current branch | 
|  | 567 | </p> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 568 | <div class="para"><p>If you have an unfortunate branch that is named <tt>hello.c</tt>, this | 
| Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 569 | step would be confused as an instruction to switch to that branch. | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 570 | You should instead write:</p></div> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 571 | <div class="listingblock"> | 
|  | 572 | <div class="content"> | 
|  | 573 | <pre><tt>$ git checkout -- hello.c</tt></pre> | 
|  | 574 | </div></div> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 575 | </li> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 576 | </ol></div> | 
| Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 577 | </li> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 578 | <li> | 
|  | 579 | <p> | 
|  | 580 | After working in a wrong branch, switching to the correct | 
| Junio C Hamano | 2b13527 | 2006-03-18 07:45:42 | [diff] [blame] | 581 | branch would be done using: | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 582 | </p> | 
|  | 583 | <div class="listingblock"> | 
|  | 584 | <div class="content"> | 
|  | 585 | <pre><tt>$ git checkout mytopic</tt></pre> | 
|  | 586 | </div></div> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 587 | <div class="para"><p>However, your "wrong" branch and correct "mytopic" branch may | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 588 | differ in files that you have locally modified, in which case, | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 589 | the above checkout would fail like this:</p></div> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 590 | <div class="listingblock"> | 
|  | 591 | <div class="content"> | 
|  | 592 | <pre><tt>$ git checkout mytopic | 
|  | 593 | fatal: Entry 'frotz' not uptodate. Cannot merge.</tt></pre> | 
|  | 594 | </div></div> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 595 | <div class="para"><p>You can give the <tt>-m</tt> flag to the command, which would try a | 
|  | 596 | three-way merge:</p></div> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 597 | <div class="listingblock"> | 
|  | 598 | <div class="content"> | 
|  | 599 | <pre><tt>$ git checkout -m mytopic | 
|  | 600 | Auto-merging frotz</tt></pre> | 
|  | 601 | </div></div> | 
| Junio C Hamano | 4604fe5 | 2008-09-19 06:37:10 | [diff] [blame] | 602 | <div class="para"><p>After this three-way merge, the local modifications are _not_ | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 603 | registered in your index file, so <tt>git diff</tt> would show you what | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 604 | changes you made since the tip of the new branch.</p></div> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 605 | </li> | 
|  | 606 | <li> | 
|  | 607 | <p> | 
|  | 608 | When a merge conflict happens during switching branches with | 
|  | 609 | the <tt>-m</tt> option, you would see something like this: | 
|  | 610 | </p> | 
|  | 611 | <div class="listingblock"> | 
|  | 612 | <div class="content"> | 
|  | 613 | <pre><tt>$ git checkout -m mytopic | 
|  | 614 | Auto-merging frotz | 
|  | 615 | merge: warning: conflicts during merge | 
|  | 616 | ERROR: Merge conflict in frotz | 
|  | 617 | fatal: merge program failed</tt></pre> | 
|  | 618 | </div></div> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 619 | <div class="para"><p>At this point, <tt>git diff</tt> shows the changes cleanly merged as in | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 620 | the previous example, as well as the changes in the conflicted | 
|  | 621 | files. Edit and resolve the conflict and mark it resolved with | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 622 | <tt>git add</tt> as usual:</p></div> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 623 | <div class="listingblock"> | 
|  | 624 | <div class="content"> | 
|  | 625 | <pre><tt>$ edit frotz | 
| Junio C Hamano | 89d4e0f | 2007-02-18 00:34:59 | [diff] [blame] | 626 | $ git add frotz</tt></pre> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 627 | </div></div> | 
|  | 628 | </li> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 629 | </ol></div> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 630 | </div> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 631 | <h2 id="_author">Author</h2> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 632 | <div class="sectionbody"> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 633 | <div class="para"><p>Written by Linus Torvalds <torvalds@osdl.org></p></div> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 634 | </div> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 635 | <h2 id="_documentation">Documentation</h2> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 636 | <div class="sectionbody"> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 637 | <div class="para"><p>Documentation by Junio C Hamano and the git-list <git@vger.kernel.org>.</p></div> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 638 | </div> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 639 | <h2 id="_git">GIT</h2> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 640 | <div class="sectionbody"> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 641 | <div class="para"><p>Part of the <a href="git.html">git(1)</a> suite</p></div> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 642 | </div> | 
|  | 643 | <div id="footer"> | 
|  | 644 | <div id="footer-text"> | 
| Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame^] | 645 | Last updated 2008-10-10 15:30:41 UTC | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 646 | </div> | 
|  | 647 | </div> | 
|  | 648 | </body> | 
|  | 649 | </html> |