| 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> | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 5 | <meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" /> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 6 | <meta name="generator" content="AsciiDoc 8.6.9" /> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 7 | <title>git-checkout(1)</title> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 8 | <style type="text/css"> | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 9 | /* Shared CSS for AsciiDoc xhtml11 and html5 backends */ | 
|  | 10 |  | 
|  | 11 | /* Default font. */ | 
|  | 12 | body { | 
|  | 13 | font-family: Georgia,serif; | 
|  | 14 | } | 
|  | 15 |  | 
|  | 16 | /* Title font. */ | 
|  | 17 | h1, h2, h3, h4, h5, h6, | 
|  | 18 | div.title, caption.title, | 
|  | 19 | thead, p.table.header, | 
|  | 20 | #toctitle, | 
|  | 21 | #author, #revnumber, #revdate, #revremark, | 
|  | 22 | #footer { | 
|  | 23 | font-family: Arial,Helvetica,sans-serif; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 24 | } | 
|  | 25 |  | 
|  | 26 | body { | 
|  | 27 | margin: 1em 5% 1em 5%; | 
|  | 28 | } | 
|  | 29 |  | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 30 | a { | 
|  | 31 | color: blue; | 
|  | 32 | text-decoration: underline; | 
|  | 33 | } | 
|  | 34 | a:visited { | 
|  | 35 | color: fuchsia; | 
|  | 36 | } | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 37 |  | 
|  | 38 | em { | 
|  | 39 | font-style: italic; | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 40 | color: navy; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 41 | } | 
|  | 42 |  | 
|  | 43 | strong { | 
|  | 44 | font-weight: bold; | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 45 | color: #083194; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 46 | } | 
|  | 47 |  | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 48 | h1, h2, h3, h4, h5, h6 { | 
|  | 49 | color: #527bbd; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 50 | margin-top: 1.2em; | 
|  | 51 | margin-bottom: 0.5em; | 
|  | 52 | line-height: 1.3; | 
|  | 53 | } | 
|  | 54 |  | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 55 | h1, h2, h3 { | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 56 | border-bottom: 2px solid silver; | 
|  | 57 | } | 
|  | 58 | h2 { | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 59 | padding-top: 0.5em; | 
|  | 60 | } | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 61 | h3 { | 
|  | 62 | float: left; | 
|  | 63 | } | 
|  | 64 | h3 + * { | 
|  | 65 | clear: left; | 
|  | 66 | } | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 67 | h5 { | 
|  | 68 | font-size: 1.0em; | 
|  | 69 | } | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 70 |  | 
|  | 71 | div.sectionbody { | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 72 | margin-left: 0; | 
|  | 73 | } | 
|  | 74 |  | 
|  | 75 | hr { | 
|  | 76 | border: 1px solid silver; | 
|  | 77 | } | 
|  | 78 |  | 
|  | 79 | p { | 
|  | 80 | margin-top: 0.5em; | 
|  | 81 | margin-bottom: 0.5em; | 
|  | 82 | } | 
|  | 83 |  | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 84 | ul, ol, li > p { | 
|  | 85 | margin-top: 0; | 
|  | 86 | } | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 87 | ul > li { color: #aaa; } | 
|  | 88 | ul > li > * { color: black; } | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 89 |  | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 90 | .monospaced, code, pre { | 
|  | 91 | font-family: "Courier New", Courier, monospace; | 
|  | 92 | font-size: inherit; | 
|  | 93 | color: navy; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 94 | padding: 0; | 
|  | 95 | margin: 0; | 
|  | 96 | } | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 97 | pre { | 
|  | 98 | white-space: pre-wrap; | 
|  | 99 | } | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 100 |  | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 101 | #author { | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 102 | color: #527bbd; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 103 | font-weight: bold; | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 104 | font-size: 1.1em; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 105 | } | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 106 | #email { | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 107 | } | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 108 | #revnumber, #revdate, #revremark { | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 109 | } | 
|  | 110 |  | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 111 | #footer { | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 112 | font-size: small; | 
|  | 113 | border-top: 2px solid silver; | 
|  | 114 | padding-top: 0.5em; | 
|  | 115 | margin-top: 4.0em; | 
|  | 116 | } | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 117 | #footer-text { | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 118 | float: left; | 
|  | 119 | padding-bottom: 0.5em; | 
|  | 120 | } | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 121 | #footer-badges { | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 122 | float: right; | 
|  | 123 | padding-bottom: 0.5em; | 
|  | 124 | } | 
|  | 125 |  | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 126 | #preamble { | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 127 | margin-top: 1.5em; | 
|  | 128 | margin-bottom: 1.5em; | 
|  | 129 | } | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 130 | div.imageblock, div.exampleblock, div.verseblock, | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 131 | div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock, | 
|  | 132 | div.admonitionblock { | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 133 | margin-top: 1.0em; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 134 | margin-bottom: 1.5em; | 
|  | 135 | } | 
|  | 136 | div.admonitionblock { | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 137 | margin-top: 2.0em; | 
|  | 138 | margin-bottom: 2.0em; | 
|  | 139 | margin-right: 10%; | 
|  | 140 | color: #606060; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 141 | } | 
|  | 142 |  | 
|  | 143 | div.content { /* Block element content. */ | 
|  | 144 | padding: 0; | 
|  | 145 | } | 
|  | 146 |  | 
|  | 147 | /* Block element titles. */ | 
|  | 148 | div.title, caption.title { | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 149 | color: #527bbd; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 150 | font-weight: bold; | 
|  | 151 | text-align: left; | 
|  | 152 | margin-top: 1.0em; | 
|  | 153 | margin-bottom: 0.5em; | 
|  | 154 | } | 
|  | 155 | div.title + * { | 
|  | 156 | margin-top: 0; | 
|  | 157 | } | 
|  | 158 |  | 
|  | 159 | td div.title:first-child { | 
|  | 160 | margin-top: 0.0em; | 
|  | 161 | } | 
|  | 162 | div.content div.title:first-child { | 
|  | 163 | margin-top: 0.0em; | 
|  | 164 | } | 
|  | 165 | div.content + div.title { | 
|  | 166 | margin-top: 0.0em; | 
|  | 167 | } | 
|  | 168 |  | 
|  | 169 | div.sidebarblock > div.content { | 
|  | 170 | background: #ffffee; | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 171 | border: 1px solid #dddddd; | 
|  | 172 | border-left: 4px solid #f0f0f0; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 173 | padding: 0.5em; | 
|  | 174 | } | 
|  | 175 |  | 
|  | 176 | div.listingblock > div.content { | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 177 | border: 1px solid #dddddd; | 
|  | 178 | border-left: 5px solid #f0f0f0; | 
|  | 179 | background: #f8f8f8; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 180 | padding: 0.5em; | 
|  | 181 | } | 
|  | 182 |  | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 183 | div.quoteblock, div.verseblock { | 
|  | 184 | padding-left: 1.0em; | 
|  | 185 | margin-left: 1.0em; | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 186 | margin-right: 10%; | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 187 | border-left: 5px solid #f0f0f0; | 
|  | 188 | color: #888; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 189 | } | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 190 |  | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 191 | div.quoteblock > div.attribution { | 
|  | 192 | padding-top: 0.5em; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 193 | text-align: right; | 
|  | 194 | } | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 195 |  | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 196 | div.verseblock > pre.content { | 
|  | 197 | font-family: inherit; | 
|  | 198 | font-size: inherit; | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 199 | } | 
|  | 200 | div.verseblock > div.attribution { | 
|  | 201 | padding-top: 0.75em; | 
|  | 202 | text-align: left; | 
|  | 203 | } | 
|  | 204 | /* DEPRECATED: Pre version 8.2.7 verse style literal block. */ | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 205 | div.verseblock + div.attribution { | 
|  | 206 | text-align: left; | 
|  | 207 | } | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 208 |  | 
|  | 209 | div.admonitionblock .icon { | 
|  | 210 | vertical-align: top; | 
|  | 211 | font-size: 1.1em; | 
|  | 212 | font-weight: bold; | 
|  | 213 | text-decoration: underline; | 
|  | 214 | color: #527bbd; | 
|  | 215 | padding-right: 0.5em; | 
|  | 216 | } | 
|  | 217 | div.admonitionblock td.content { | 
|  | 218 | padding-left: 0.5em; | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 219 | border-left: 3px solid #dddddd; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 220 | } | 
|  | 221 |  | 
|  | 222 | div.exampleblock > div.content { | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 223 | border-left: 3px solid #dddddd; | 
|  | 224 | padding-left: 0.5em; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 225 | } | 
|  | 226 |  | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 227 | div.imageblock div.content { padding-left: 0; } | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 228 | span.image img { border-style: none; vertical-align: text-bottom; } | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 229 | a.image:visited { color: white; } | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 230 |  | 
|  | 231 | dl { | 
|  | 232 | margin-top: 0.8em; | 
|  | 233 | margin-bottom: 0.8em; | 
|  | 234 | } | 
|  | 235 | dt { | 
|  | 236 | margin-top: 0.5em; | 
|  | 237 | margin-bottom: 0; | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 238 | font-style: normal; | 
|  | 239 | color: navy; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 240 | } | 
|  | 241 | dd > *:first-child { | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 242 | margin-top: 0.1em; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 243 | } | 
|  | 244 |  | 
|  | 245 | ul, ol { | 
|  | 246 | list-style-position: outside; | 
|  | 247 | } | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 248 | ol.arabic { | 
|  | 249 | list-style-type: decimal; | 
|  | 250 | } | 
|  | 251 | ol.loweralpha { | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 252 | list-style-type: lower-alpha; | 
|  | 253 | } | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 254 | ol.upperalpha { | 
|  | 255 | list-style-type: upper-alpha; | 
|  | 256 | } | 
|  | 257 | ol.lowerroman { | 
|  | 258 | list-style-type: lower-roman; | 
|  | 259 | } | 
|  | 260 | ol.upperroman { | 
|  | 261 | list-style-type: upper-roman; | 
|  | 262 | } | 
|  | 263 |  | 
|  | 264 | div.compact ul, div.compact ol, | 
|  | 265 | div.compact p, div.compact p, | 
|  | 266 | div.compact div, div.compact div { | 
|  | 267 | margin-top: 0.1em; | 
|  | 268 | margin-bottom: 0.1em; | 
|  | 269 | } | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 270 |  | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 271 | tfoot { | 
|  | 272 | font-weight: bold; | 
|  | 273 | } | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 274 | td > div.verse { | 
|  | 275 | white-space: pre; | 
|  | 276 | } | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 277 |  | 
|  | 278 | div.hdlist { | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 279 | margin-top: 0.8em; | 
|  | 280 | margin-bottom: 0.8em; | 
|  | 281 | } | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 282 | div.hdlist tr { | 
|  | 283 | padding-bottom: 15px; | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 284 | } | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 285 | dt.hdlist1.strong, td.hdlist1.strong { | 
|  | 286 | font-weight: bold; | 
|  | 287 | } | 
|  | 288 | td.hdlist1 { | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 289 | vertical-align: top; | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 290 | font-style: normal; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 291 | padding-right: 0.8em; | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 292 | color: navy; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 293 | } | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 294 | td.hdlist2 { | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 295 | vertical-align: top; | 
|  | 296 | } | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 297 | div.hdlist.compact tr { | 
|  | 298 | margin: 0; | 
|  | 299 | padding-bottom: 0; | 
|  | 300 | } | 
|  | 301 |  | 
|  | 302 | .comment { | 
|  | 303 | background: yellow; | 
|  | 304 | } | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 305 |  | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 306 | .footnote, .footnoteref { | 
|  | 307 | font-size: 0.8em; | 
|  | 308 | } | 
|  | 309 |  | 
|  | 310 | span.footnote, span.footnoteref { | 
|  | 311 | vertical-align: super; | 
|  | 312 | } | 
|  | 313 |  | 
|  | 314 | #footnotes { | 
|  | 315 | margin: 20px 0 20px 0; | 
|  | 316 | padding: 7px 0 0 0; | 
|  | 317 | } | 
|  | 318 |  | 
|  | 319 | #footnotes div.footnote { | 
|  | 320 | margin: 0 0 5px 0; | 
|  | 321 | } | 
|  | 322 |  | 
|  | 323 | #footnotes hr { | 
|  | 324 | border: none; | 
|  | 325 | border-top: 1px solid silver; | 
|  | 326 | height: 1px; | 
|  | 327 | text-align: left; | 
|  | 328 | margin-left: 0; | 
|  | 329 | width: 20%; | 
|  | 330 | min-width: 100px; | 
|  | 331 | } | 
|  | 332 |  | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 333 | div.colist td { | 
|  | 334 | padding-right: 0.5em; | 
|  | 335 | padding-bottom: 0.3em; | 
|  | 336 | vertical-align: top; | 
|  | 337 | } | 
|  | 338 | div.colist td img { | 
|  | 339 | margin-top: 0.3em; | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 340 | } | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 341 |  | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 342 | @media print { | 
|  | 343 | #footer-badges { display: none; } | 
|  | 344 | } | 
|  | 345 |  | 
|  | 346 | #toc { | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 347 | margin-bottom: 2.5em; | 
|  | 348 | } | 
|  | 349 |  | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 350 | #toctitle { | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 351 | color: #527bbd; | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 352 | font-size: 1.1em; | 
|  | 353 | font-weight: bold; | 
|  | 354 | margin-top: 1.0em; | 
|  | 355 | margin-bottom: 0.1em; | 
|  | 356 | } | 
|  | 357 |  | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 358 | div.toclevel0, div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 { | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 359 | margin-top: 0; | 
|  | 360 | margin-bottom: 0; | 
|  | 361 | } | 
|  | 362 | div.toclevel2 { | 
|  | 363 | margin-left: 2em; | 
|  | 364 | font-size: 0.9em; | 
|  | 365 | } | 
|  | 366 | div.toclevel3 { | 
|  | 367 | margin-left: 4em; | 
|  | 368 | font-size: 0.9em; | 
|  | 369 | } | 
|  | 370 | div.toclevel4 { | 
|  | 371 | margin-left: 6em; | 
|  | 372 | font-size: 0.9em; | 
|  | 373 | } | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 374 |  | 
|  | 375 | span.aqua { color: aqua; } | 
|  | 376 | span.black { color: black; } | 
|  | 377 | span.blue { color: blue; } | 
|  | 378 | span.fuchsia { color: fuchsia; } | 
|  | 379 | span.gray { color: gray; } | 
|  | 380 | span.green { color: green; } | 
|  | 381 | span.lime { color: lime; } | 
|  | 382 | span.maroon { color: maroon; } | 
|  | 383 | span.navy { color: navy; } | 
|  | 384 | span.olive { color: olive; } | 
|  | 385 | span.purple { color: purple; } | 
|  | 386 | span.red { color: red; } | 
|  | 387 | span.silver { color: silver; } | 
|  | 388 | span.teal { color: teal; } | 
|  | 389 | span.white { color: white; } | 
|  | 390 | span.yellow { color: yellow; } | 
|  | 391 |  | 
|  | 392 | span.aqua-background { background: aqua; } | 
|  | 393 | span.black-background { background: black; } | 
|  | 394 | span.blue-background { background: blue; } | 
|  | 395 | span.fuchsia-background { background: fuchsia; } | 
|  | 396 | span.gray-background { background: gray; } | 
|  | 397 | span.green-background { background: green; } | 
|  | 398 | span.lime-background { background: lime; } | 
|  | 399 | span.maroon-background { background: maroon; } | 
|  | 400 | span.navy-background { background: navy; } | 
|  | 401 | span.olive-background { background: olive; } | 
|  | 402 | span.purple-background { background: purple; } | 
|  | 403 | span.red-background { background: red; } | 
|  | 404 | span.silver-background { background: silver; } | 
|  | 405 | span.teal-background { background: teal; } | 
|  | 406 | span.white-background { background: white; } | 
|  | 407 | span.yellow-background { background: yellow; } | 
|  | 408 |  | 
|  | 409 | span.big { font-size: 2em; } | 
|  | 410 | span.small { font-size: 0.6em; } | 
|  | 411 |  | 
|  | 412 | span.underline { text-decoration: underline; } | 
|  | 413 | span.overline { text-decoration: overline; } | 
|  | 414 | span.line-through { text-decoration: line-through; } | 
|  | 415 |  | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 416 | div.unbreakable { page-break-inside: avoid; } | 
|  | 417 |  | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 418 |  | 
|  | 419 | /* | 
|  | 420 | * xhtml11 specific | 
|  | 421 | * | 
|  | 422 | * */ | 
|  | 423 |  | 
|  | 424 | div.tableblock { | 
|  | 425 | margin-top: 1.0em; | 
|  | 426 | margin-bottom: 1.5em; | 
|  | 427 | } | 
|  | 428 | div.tableblock > table { | 
|  | 429 | border: 3px solid #527bbd; | 
|  | 430 | } | 
|  | 431 | thead, p.table.header { | 
|  | 432 | font-weight: bold; | 
|  | 433 | color: #527bbd; | 
|  | 434 | } | 
|  | 435 | p.table { | 
|  | 436 | margin-top: 0; | 
|  | 437 | } | 
|  | 438 | /* Because the table frame attribute is overriden by CSS in most browsers. */ | 
|  | 439 | div.tableblock > table[frame="void"] { | 
|  | 440 | border-style: none; | 
|  | 441 | } | 
|  | 442 | div.tableblock > table[frame="hsides"] { | 
|  | 443 | border-left-style: none; | 
|  | 444 | border-right-style: none; | 
|  | 445 | } | 
|  | 446 | div.tableblock > table[frame="vsides"] { | 
|  | 447 | border-top-style: none; | 
|  | 448 | border-bottom-style: none; | 
|  | 449 | } | 
|  | 450 |  | 
|  | 451 |  | 
|  | 452 | /* | 
|  | 453 | * html5 specific | 
|  | 454 | * | 
|  | 455 | * */ | 
|  | 456 |  | 
|  | 457 | table.tableblock { | 
|  | 458 | margin-top: 1.0em; | 
|  | 459 | margin-bottom: 1.5em; | 
|  | 460 | } | 
|  | 461 | thead, p.tableblock.header { | 
|  | 462 | font-weight: bold; | 
|  | 463 | color: #527bbd; | 
|  | 464 | } | 
|  | 465 | p.tableblock { | 
|  | 466 | margin-top: 0; | 
|  | 467 | } | 
|  | 468 | table.tableblock { | 
|  | 469 | border-width: 3px; | 
|  | 470 | border-spacing: 0px; | 
|  | 471 | border-style: solid; | 
|  | 472 | border-color: #527bbd; | 
|  | 473 | border-collapse: collapse; | 
|  | 474 | } | 
|  | 475 | th.tableblock, td.tableblock { | 
|  | 476 | border-width: 1px; | 
|  | 477 | padding: 4px; | 
|  | 478 | border-style: solid; | 
|  | 479 | border-color: #527bbd; | 
|  | 480 | } | 
|  | 481 |  | 
|  | 482 | table.tableblock.frame-topbot { | 
|  | 483 | border-left-style: hidden; | 
|  | 484 | border-right-style: hidden; | 
|  | 485 | } | 
|  | 486 | table.tableblock.frame-sides { | 
|  | 487 | border-top-style: hidden; | 
|  | 488 | border-bottom-style: hidden; | 
|  | 489 | } | 
|  | 490 | table.tableblock.frame-none { | 
|  | 491 | border-style: hidden; | 
|  | 492 | } | 
|  | 493 |  | 
|  | 494 | th.tableblock.halign-left, td.tableblock.halign-left { | 
|  | 495 | text-align: left; | 
|  | 496 | } | 
|  | 497 | th.tableblock.halign-center, td.tableblock.halign-center { | 
|  | 498 | text-align: center; | 
|  | 499 | } | 
|  | 500 | th.tableblock.halign-right, td.tableblock.halign-right { | 
|  | 501 | text-align: right; | 
|  | 502 | } | 
|  | 503 |  | 
|  | 504 | th.tableblock.valign-top, td.tableblock.valign-top { | 
|  | 505 | vertical-align: top; | 
|  | 506 | } | 
|  | 507 | th.tableblock.valign-middle, td.tableblock.valign-middle { | 
|  | 508 | vertical-align: middle; | 
|  | 509 | } | 
|  | 510 | th.tableblock.valign-bottom, td.tableblock.valign-bottom { | 
|  | 511 | vertical-align: bottom; | 
|  | 512 | } | 
|  | 513 |  | 
|  | 514 |  | 
|  | 515 | /* | 
|  | 516 | * manpage specific | 
|  | 517 | * | 
|  | 518 | * */ | 
|  | 519 |  | 
|  | 520 | body.manpage h1 { | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 521 | padding-top: 0.5em; | 
|  | 522 | padding-bottom: 0.5em; | 
|  | 523 | border-top: 2px solid silver; | 
|  | 524 | border-bottom: 2px solid silver; | 
|  | 525 | } | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 526 | body.manpage h2 { | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 527 | border-style: none; | 
|  | 528 | } | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 529 | body.manpage div.sectionbody { | 
|  | 530 | margin-left: 3em; | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 531 | } | 
|  | 532 |  | 
|  | 533 | @media print { | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 534 | body.manpage div#toc { display: none; } | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 535 | } | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 536 |  | 
|  | 537 |  | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 538 | </style> | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 539 | <script type="text/javascript"> | 
|  | 540 | /*<![CDATA[*/ | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 541 | var asciidoc = { // Namespace. | 
|  | 542 |  | 
|  | 543 | ///////////////////////////////////////////////////////////////////// | 
|  | 544 | // Table Of Contents generator | 
|  | 545 | ///////////////////////////////////////////////////////////////////// | 
|  | 546 |  | 
|  | 547 | /* Author: Mihai Bazon, September 2002 | 
|  | 548 | * http://students.infoiasi.ro/~mishoo | 
|  | 549 | * | 
|  | 550 | * Table Of Content generator | 
|  | 551 | * Version: 0.4 | 
|  | 552 | * | 
|  | 553 | * Feel free to use this script under the terms of the GNU General Public | 
|  | 554 | * License, as long as you do not remove or alter this notice. | 
|  | 555 | */ | 
|  | 556 |  | 
|  | 557 | /* modified by Troy D. Hanson, September 2006. License: GPL */ | 
|  | 558 | /* modified by Stuart Rackham, 2006, 2009. License: GPL */ | 
|  | 559 |  | 
|  | 560 | // toclevels = 1..4. | 
|  | 561 | toc: function (toclevels) { | 
|  | 562 |  | 
|  | 563 | function getText(el) { | 
|  | 564 | var text = ""; | 
|  | 565 | for (var i = el.firstChild; i != null; i = i.nextSibling) { | 
|  | 566 | if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants. | 
|  | 567 | text += i.data; | 
|  | 568 | else if (i.firstChild != null) | 
|  | 569 | text += getText(i); | 
|  | 570 | } | 
|  | 571 | return text; | 
|  | 572 | } | 
|  | 573 |  | 
|  | 574 | function TocEntry(el, text, toclevel) { | 
|  | 575 | this.element = el; | 
|  | 576 | this.text = text; | 
|  | 577 | this.toclevel = toclevel; | 
|  | 578 | } | 
|  | 579 |  | 
|  | 580 | function tocEntries(el, toclevels) { | 
|  | 581 | var result = new Array; | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 582 | var re = new RegExp('[hH]([1-'+(toclevels+1)+'])'); | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 583 | // Function that scans the DOM tree for header elements (the DOM2 | 
|  | 584 | // nodeIterator API would be a better technique but not supported by all | 
|  | 585 | // browsers). | 
|  | 586 | var iterate = function (el) { | 
|  | 587 | for (var i = el.firstChild; i != null; i = i.nextSibling) { | 
|  | 588 | if (i.nodeType == 1 /* Node.ELEMENT_NODE */) { | 
|  | 589 | var mo = re.exec(i.tagName); | 
|  | 590 | if (mo && (i.getAttribute("class") || i.getAttribute("className")) != "float") { | 
|  | 591 | result[result.length] = new TocEntry(i, getText(i), mo[1]-1); | 
|  | 592 | } | 
|  | 593 | iterate(i); | 
|  | 594 | } | 
|  | 595 | } | 
|  | 596 | } | 
|  | 597 | iterate(el); | 
|  | 598 | return result; | 
|  | 599 | } | 
|  | 600 |  | 
|  | 601 | var toc = document.getElementById("toc"); | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 602 | if (!toc) { | 
|  | 603 | return; | 
|  | 604 | } | 
|  | 605 |  | 
|  | 606 | // Delete existing TOC entries in case we're reloading the TOC. | 
|  | 607 | var tocEntriesToRemove = []; | 
|  | 608 | var i; | 
|  | 609 | for (i = 0; i < toc.childNodes.length; i++) { | 
|  | 610 | var entry = toc.childNodes[i]; | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 611 | if (entry.nodeName.toLowerCase() == 'div' | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 612 | && entry.getAttribute("class") | 
|  | 613 | && entry.getAttribute("class").match(/^toclevel/)) | 
|  | 614 | tocEntriesToRemove.push(entry); | 
|  | 615 | } | 
|  | 616 | for (i = 0; i < tocEntriesToRemove.length; i++) { | 
|  | 617 | toc.removeChild(tocEntriesToRemove[i]); | 
|  | 618 | } | 
|  | 619 |  | 
|  | 620 | // Rebuild TOC entries. | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 621 | var entries = tocEntries(document.getElementById("content"), toclevels); | 
|  | 622 | for (var i = 0; i < entries.length; ++i) { | 
|  | 623 | var entry = entries[i]; | 
|  | 624 | if (entry.element.id == "") | 
|  | 625 | entry.element.id = "_toc_" + i; | 
|  | 626 | var a = document.createElement("a"); | 
|  | 627 | a.href = "#" + entry.element.id; | 
|  | 628 | a.appendChild(document.createTextNode(entry.text)); | 
|  | 629 | var div = document.createElement("div"); | 
|  | 630 | div.appendChild(a); | 
|  | 631 | div.className = "toclevel" + entry.toclevel; | 
|  | 632 | toc.appendChild(div); | 
|  | 633 | } | 
|  | 634 | if (entries.length == 0) | 
|  | 635 | toc.parentNode.removeChild(toc); | 
|  | 636 | }, | 
|  | 637 |  | 
|  | 638 |  | 
|  | 639 | ///////////////////////////////////////////////////////////////////// | 
|  | 640 | // Footnotes generator | 
|  | 641 | ///////////////////////////////////////////////////////////////////// | 
|  | 642 |  | 
|  | 643 | /* Based on footnote generation code from: | 
|  | 644 | * http://www.brandspankingnew.net/archive/2005/07/format_footnote.html | 
|  | 645 | */ | 
|  | 646 |  | 
|  | 647 | footnotes: function () { | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 648 | // Delete existing footnote entries in case we're reloading the footnodes. | 
|  | 649 | var i; | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 650 | var noteholder = document.getElementById("footnotes"); | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 651 | if (!noteholder) { | 
|  | 652 | return; | 
|  | 653 | } | 
|  | 654 | var entriesToRemove = []; | 
|  | 655 | for (i = 0; i < noteholder.childNodes.length; i++) { | 
|  | 656 | var entry = noteholder.childNodes[i]; | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 657 | if (entry.nodeName.toLowerCase() == 'div' && entry.getAttribute("class") == "footnote") | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 658 | entriesToRemove.push(entry); | 
|  | 659 | } | 
|  | 660 | for (i = 0; i < entriesToRemove.length; i++) { | 
|  | 661 | noteholder.removeChild(entriesToRemove[i]); | 
|  | 662 | } | 
|  | 663 |  | 
|  | 664 | // Rebuild footnote entries. | 
|  | 665 | var cont = document.getElementById("content"); | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 666 | var spans = cont.getElementsByTagName("span"); | 
|  | 667 | var refs = {}; | 
|  | 668 | var n = 0; | 
|  | 669 | for (i=0; i<spans.length; i++) { | 
|  | 670 | if (spans[i].className == "footnote") { | 
|  | 671 | n++; | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 672 | var note = spans[i].getAttribute("data-note"); | 
|  | 673 | if (!note) { | 
|  | 674 | // Use [\s\S] in place of . so multi-line matches work. | 
|  | 675 | // Because JavaScript has no s (dotall) regex flag. | 
|  | 676 | note = spans[i].innerHTML.match(/\s*\[([\s\S]*)]\s*/)[1]; | 
|  | 677 | spans[i].innerHTML = | 
|  | 678 | "[<a id='_footnoteref_" + n + "' href='#_footnote_" + n + | 
|  | 679 | "' title='View footnote' class='footnote'>" + n + "</a>]"; | 
|  | 680 | spans[i].setAttribute("data-note", note); | 
|  | 681 | } | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 682 | noteholder.innerHTML += | 
|  | 683 | "<div class='footnote' id='_footnote_" + n + "'>" + | 
|  | 684 | "<a href='#_footnoteref_" + n + "' title='Return to text'>" + | 
|  | 685 | n + "</a>. " + note + "</div>"; | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 686 | var id =spans[i].getAttribute("id"); | 
|  | 687 | if (id != null) refs["#"+id] = n; | 
|  | 688 | } | 
|  | 689 | } | 
|  | 690 | if (n == 0) | 
|  | 691 | noteholder.parentNode.removeChild(noteholder); | 
|  | 692 | else { | 
|  | 693 | // Process footnoterefs. | 
|  | 694 | for (i=0; i<spans.length; i++) { | 
|  | 695 | if (spans[i].className == "footnoteref") { | 
|  | 696 | var href = spans[i].getElementsByTagName("a")[0].getAttribute("href"); | 
|  | 697 | href = href.match(/#.*/)[0]; // Because IE return full URL. | 
|  | 698 | n = refs[href]; | 
|  | 699 | spans[i].innerHTML = | 
|  | 700 | "[<a href='#_footnote_" + n + | 
|  | 701 | "' title='View footnote' class='footnote'>" + n + "</a>]"; | 
|  | 702 | } | 
|  | 703 | } | 
|  | 704 | } | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 705 | }, | 
|  | 706 |  | 
|  | 707 | install: function(toclevels) { | 
|  | 708 | var timerId; | 
|  | 709 |  | 
|  | 710 | function reinstall() { | 
|  | 711 | asciidoc.footnotes(); | 
|  | 712 | if (toclevels) { | 
|  | 713 | asciidoc.toc(toclevels); | 
|  | 714 | } | 
|  | 715 | } | 
|  | 716 |  | 
|  | 717 | function reinstallAndRemoveTimer() { | 
|  | 718 | clearInterval(timerId); | 
|  | 719 | reinstall(); | 
|  | 720 | } | 
|  | 721 |  | 
|  | 722 | timerId = setInterval(reinstall, 500); | 
|  | 723 | if (document.addEventListener) | 
|  | 724 | document.addEventListener("DOMContentLoaded", reinstallAndRemoveTimer, false); | 
|  | 725 | else | 
|  | 726 | window.onload = reinstallAndRemoveTimer; | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 727 | } | 
|  | 728 |  | 
|  | 729 | } | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 730 | asciidoc.install(); | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 731 | /*]]>*/ | 
|  | 732 | </script> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 733 | </head> | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 734 | <body class="manpage"> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 735 | <div id="header"> | 
|  | 736 | <h1> | 
|  | 737 | git-checkout(1) Manual Page | 
|  | 738 | </h1> | 
|  | 739 | <h2>NAME</h2> | 
|  | 740 | <div class="sectionbody"> | 
|  | 741 | <p>git-checkout - | 
| Junio C Hamano | 823eebb | 2015-07-10 22:29:34 | [diff] [blame] | 742 | Switch branches or restore working tree files | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 743 | </p> | 
|  | 744 | </div> | 
|  | 745 | </div> | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 746 | <div id="content"> | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 747 | <div class="sect1"> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 748 | <h2 id="_synopsis">SYNOPSIS</h2> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 749 | <div class="sectionbody"> | 
| Junio C Hamano | 2b13527 | 2006-03-18 07:45:42 | [diff] [blame] | 750 | <div class="verseblock"> | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 751 | <pre class="content"><em>git checkout</em> [-q] [-f] [-m] [<branch>] | 
| Junio C Hamano | f2d4a13 | 2013-10-18 04:34:41 | [diff] [blame] | 752 | <em>git checkout</em> [-q] [-f] [-m] --detach [<branch>] | 
|  | 753 | <em>git checkout</em> [-q] [-f] [-m] [--detach] <commit> | 
| Junio C Hamano | 619596a | 2010-08-18 22:15:35 | [diff] [blame] | 754 | <em>git checkout</em> [-q] [-f] [-m] [[-b|-B|--orphan] <new_branch>] [<start_point>] | 
| Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 755 | <em>git checkout</em> [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>… | 
| Junio C Hamano | da6200c | 2017-10-17 06:27:31 | [diff] [blame] | 756 | <em>git checkout</em> [<tree-ish>] [--] <pathspec>… | 
|  | 757 | <em>git checkout</em> (-p|--patch) [<tree-ish>] [--] [<paths>…]</pre> | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 758 | <div class="attribution"> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 759 | </div></div> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 760 | </div> | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 761 | </div> | 
|  | 762 | <div class="sect1"> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 763 | <h2 id="_description">DESCRIPTION</h2> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 764 | <div class="sectionbody"> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 765 | <div class="paragraph"><p>Updates files in the working tree to match the version in the index | 
| Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 766 | or the specified tree. If no paths are given, <em>git checkout</em> will | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 767 | also update <code>HEAD</code> to set the specified branch as the current | 
| Junio C Hamano | 3bd66e9 | 2009-04-18 06:17:56 | [diff] [blame] | 768 | branch.</p></div> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 769 | <div class="dlist"><dl> | 
|  | 770 | <dt class="hdlist1"> | 
| Junio C Hamano | db81b99 | 2012-12-21 23:49:12 | [diff] [blame] | 771 | <em>git checkout</em> <branch> | 
| Junio C Hamano | 63c2bc9 | 2011-02-28 06:41:28 | [diff] [blame] | 772 | </dt> | 
| Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 773 | <dd> | 
|  | 774 | <p> | 
| Junio C Hamano | db81b99 | 2012-12-21 23:49:12 | [diff] [blame] | 775 | To prepare for working on <branch>, switch to it by updating | 
|  | 776 | the index and the files in the working tree, and by pointing | 
|  | 777 | HEAD at the branch. Local modifications to the files in the | 
|  | 778 | working tree are kept, so that they can be committed to the | 
|  | 779 | <branch>. | 
| Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 780 | </p> | 
| Junio C Hamano | db81b99 | 2012-12-21 23:49:12 | [diff] [blame] | 781 | <div class="paragraph"><p>If <branch> is not found but there does exist a tracking branch in | 
|  | 782 | exactly one remote (call it <remote>) with a matching name, treat as | 
|  | 783 | equivalent to</p></div> | 
|  | 784 | <div class="listingblock"> | 
|  | 785 | <div class="content"> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 786 | <pre><code>$ git checkout -b <branch> --track <remote>/<branch></code></pre> | 
| Junio C Hamano | db81b99 | 2012-12-21 23:49:12 | [diff] [blame] | 787 | </div></div> | 
|  | 788 | <div class="paragraph"><p>You could omit <branch>, in which case the command degenerates to | 
| Junio C Hamano | d4bbec0 | 2017-09-25 07:24:53 | [diff] [blame] | 789 | "check out the current branch", which is a glorified no-op with | 
| Junio C Hamano | db81b99 | 2012-12-21 23:49:12 | [diff] [blame] | 790 | rather expensive side-effects to show only the tracking information, | 
|  | 791 | if exists, for the current branch.</p></div> | 
|  | 792 | </dd> | 
|  | 793 | <dt class="hdlist1"> | 
|  | 794 | <em>git checkout</em> -b|-B <new_branch> [<start point>] | 
|  | 795 | </dt> | 
|  | 796 | <dd> | 
|  | 797 | <p> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 798 | Specifying <code>-b</code> causes a new branch to be created as if | 
| Junio C Hamano | db81b99 | 2012-12-21 23:49:12 | [diff] [blame] | 799 | <a href="git-branch.html">git-branch(1)</a> were called and then checked out. In | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 800 | this case you can use the <code>--track</code> or <code>--no-track</code> options, | 
| Junio C Hamano | db81b99 | 2012-12-21 23:49:12 | [diff] [blame] | 801 | which will be passed to <em>git branch</em>. As a convenience, | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 802 | <code>--track</code> without <code>-b</code> implies branch creation; see the | 
|  | 803 | description of <code>--track</code> below. | 
| Junio C Hamano | db81b99 | 2012-12-21 23:49:12 | [diff] [blame] | 804 | </p> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 805 | <div class="paragraph"><p>If <code>-B</code> is given, <new_branch> is created if it doesn’t exist; otherwise, it | 
| Junio C Hamano | 619596a | 2010-08-18 22:15:35 | [diff] [blame] | 806 | is reset. This is the transactional equivalent of</p></div> | 
|  | 807 | <div class="listingblock"> | 
|  | 808 | <div class="content"> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 809 | <pre><code>$ git branch -f <branch> [<start point>] | 
|  | 810 | $ git checkout <branch></code></pre> | 
| Junio C Hamano | 619596a | 2010-08-18 22:15:35 | [diff] [blame] | 811 | </div></div> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 812 | <div class="paragraph"><p>that is to say, the branch is not reset/created unless "git checkout" is | 
| Junio C Hamano | 619596a | 2010-08-18 22:15:35 | [diff] [blame] | 813 | successful.</p></div> | 
| Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 814 | </dd> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 815 | <dt class="hdlist1"> | 
| Junio C Hamano | db81b99 | 2012-12-21 23:49:12 | [diff] [blame] | 816 | <em>git checkout</em> --detach [<branch>] | 
|  | 817 | </dt> | 
|  | 818 | <dt class="hdlist1"> | 
| Junio C Hamano | f2d4a13 | 2013-10-18 04:34:41 | [diff] [blame] | 819 | <em>git checkout</em> [--detach] <commit> | 
| Junio C Hamano | db81b99 | 2012-12-21 23:49:12 | [diff] [blame] | 820 | </dt> | 
|  | 821 | <dd> | 
|  | 822 | <p> | 
|  | 823 | Prepare to work on top of <commit>, by detaching HEAD at it | 
|  | 824 | (see "DETACHED HEAD" section), and updating the index and the | 
|  | 825 | files in the working tree. Local modifications to the files | 
|  | 826 | in the working tree are kept, so that the resulting working | 
|  | 827 | tree will be the state recorded in the commit plus the local | 
|  | 828 | modifications. | 
|  | 829 | </p> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 830 | <div class="paragraph"><p>When the <commit> argument is a branch name, the <code>--detach</code> option can | 
|  | 831 | be used to detach HEAD at the tip of the branch (<code>git checkout | 
|  | 832 | <branch></code> would check out that branch without detaching HEAD).</p></div> | 
| Junio C Hamano | f2d4a13 | 2013-10-18 04:34:41 | [diff] [blame] | 833 | <div class="paragraph"><p>Omitting <branch> detaches HEAD at the tip of the current branch.</p></div> | 
| Junio C Hamano | db81b99 | 2012-12-21 23:49:12 | [diff] [blame] | 834 | </dd> | 
|  | 835 | <dt class="hdlist1"> | 
| Junio C Hamano | da6200c | 2017-10-17 06:27:31 | [diff] [blame] | 836 | <em>git checkout</em> [<tree-ish>] [--] <pathspec>… | 
| Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 837 | </dt> | 
|  | 838 | <dd> | 
|  | 839 | <p> | 
| Junio C Hamano | da6200c | 2017-10-17 06:27:31 | [diff] [blame] | 840 | Overwrite paths in the working tree by replacing with the | 
|  | 841 | contents in the index or in the <tree-ish> (most often a | 
|  | 842 | commit). When a <tree-ish> is given, the paths that | 
|  | 843 | match the <pathspec> are updated both in the index and in | 
|  | 844 | the working tree. | 
| Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 845 | </p> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 846 | <div class="paragraph"><p>The index may contain unmerged entries because of a previous failed merge. | 
| Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 847 | By default, if you try to check out such an entry from the index, the | 
| Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 848 | checkout operation will fail and nothing will be checked out. | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 849 | Using <code>-f</code> will ignore these unmerged entries. The contents from a | 
| Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 850 | specific side of the merge can be checked out of the index by | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 851 | using <code>--ours</code> or <code>--theirs</code>. With <code>-m</code>, changes made to the working tree | 
| Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 852 | file can be discarded to re-create the original conflicted merge result.</p></div> | 
|  | 853 | </dd> | 
| Junio C Hamano | da6200c | 2017-10-17 06:27:31 | [diff] [blame] | 854 | <dt class="hdlist1"> | 
|  | 855 | <em>git checkout</em> (-p|--patch) [<tree-ish>] [--] [<pathspec>…] | 
|  | 856 | </dt> | 
|  | 857 | <dd> | 
|  | 858 | <p> | 
|  | 859 | This is similar to the "check out paths to the working tree | 
|  | 860 | from either the index or from a tree-ish" mode described | 
|  | 861 | above, but lets you use the interactive interface to show | 
|  | 862 | the "diff" output and choose which hunks to use in the | 
|  | 863 | result. See below for the description of <code>--patch</code> option. | 
|  | 864 | </p> | 
|  | 865 | </dd> | 
| Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 866 | </dl></div> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 867 | </div> | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 868 | </div> | 
|  | 869 | <div class="sect1"> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 870 | <h2 id="_options">OPTIONS</h2> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 871 | <div class="sectionbody"> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 872 | <div class="dlist"><dl> | 
|  | 873 | <dt class="hdlist1"> | 
| Junio C Hamano | 39381a7 | 2007-02-02 07:35:15 | [diff] [blame] | 874 | -q | 
|  | 875 | </dt> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 876 | <dt class="hdlist1"> | 
| Junio C Hamano | 68cfa3a | 2009-08-30 00:22:55 | [diff] [blame] | 877 | --quiet | 
|  | 878 | </dt> | 
| Junio C Hamano | 39381a7 | 2007-02-02 07:35:15 | [diff] [blame] | 879 | <dd> | 
|  | 880 | <p> | 
| Junio C Hamano | cae8627 | 2007-08-21 02:20:49 | [diff] [blame] | 881 | Quiet, suppress feedback messages. | 
| Junio C Hamano | 39381a7 | 2007-02-02 07:35:15 | [diff] [blame] | 882 | </p> | 
|  | 883 | </dd> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 884 | <dt class="hdlist1"> | 
| Junio C Hamano | 89c34e3 | 2015-11-06 23:26:20 | [diff] [blame] | 885 | --[no-]progress | 
|  | 886 | </dt> | 
|  | 887 | <dd> | 
|  | 888 | <p> | 
|  | 889 | Progress status is reported on the standard error stream | 
|  | 890 | by default when it is attached to a terminal, unless <code>--quiet</code> | 
|  | 891 | is specified. This flag enables progress reporting even if not | 
|  | 892 | attached to a terminal, regardless of <code>--quiet</code>. | 
|  | 893 | </p> | 
|  | 894 | </dd> | 
|  | 895 | <dt class="hdlist1"> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 896 | -f | 
|  | 897 | </dt> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 898 | <dt class="hdlist1"> | 
| Junio C Hamano | 68cfa3a | 2009-08-30 00:22:55 | [diff] [blame] | 899 | --force | 
|  | 900 | </dt> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 901 | <dd> | 
|  | 902 | <p> | 
| Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 903 | When switching branches, proceed even if the index or the | 
|  | 904 | working tree differs from HEAD. This is used to throw away | 
|  | 905 | local changes. | 
|  | 906 | </p> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 907 | <div class="paragraph"><p>When checking out paths from the index, do not fail upon unmerged | 
| Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 908 | entries; instead, unmerged entries are ignored.</p></div> | 
|  | 909 | </dd> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 910 | <dt class="hdlist1"> | 
| Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 911 | --ours | 
|  | 912 | </dt> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 913 | <dt class="hdlist1"> | 
| Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 914 | --theirs | 
|  | 915 | </dt> | 
|  | 916 | <dd> | 
|  | 917 | <p> | 
|  | 918 | When checking out paths from the index, check out stage #2 | 
|  | 919 | (<em>ours</em>) or #3 (<em>theirs</em>) for unmerged paths. | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 920 | </p> | 
| Junio C Hamano | d7ed404 | 2015-08-03 19:43:00 | [diff] [blame] | 921 | <div class="paragraph"><p>Note that during <code>git rebase</code> and <code>git pull --rebase</code>, <em>ours</em> and | 
|  | 922 | <em>theirs</em> may appear swapped; <code>--ours</code> gives the version from the | 
|  | 923 | branch the changes are rebased onto, while <code>--theirs</code> gives the | 
|  | 924 | version from the branch that holds your work that is being rebased.</p></div> | 
|  | 925 | <div class="paragraph"><p>This is because <code>rebase</code> is used in a workflow that treats the | 
|  | 926 | history at the remote as the shared canonical one, and treats the | 
|  | 927 | work done on the branch you are rebasing as the third-party work to | 
|  | 928 | be integrated, and you are temporarily assuming the role of the | 
|  | 929 | keeper of the canonical history during the rebase. As the keeper of | 
|  | 930 | the canonical history, you need to view the history from the remote | 
|  | 931 | as <code>ours</code> (i.e. "our shared canonical history"), while what you did | 
|  | 932 | on your side branch as <code>theirs</code> (i.e. "one contributor’s work on top | 
|  | 933 | of it").</p></div> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 934 | </dd> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 935 | <dt class="hdlist1"> | 
| Junio C Hamano | eccdd4a | 2012-09-10 23:28:17 | [diff] [blame] | 936 | -b <new_branch> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 937 | </dt> | 
|  | 938 | <dd> | 
|  | 939 | <p> | 
| Junio C Hamano | b2f5edd | 2006-05-21 10:50:09 | [diff] [blame] | 940 | Create a new branch named <new_branch> and start it at | 
| Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 941 | <start_point>; see <a href="git-branch.html">git-branch(1)</a> for details. | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 942 | </p> | 
|  | 943 | </dd> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 944 | <dt class="hdlist1"> | 
| Junio C Hamano | eccdd4a | 2012-09-10 23:28:17 | [diff] [blame] | 945 | -B <new_branch> | 
| Junio C Hamano | 619596a | 2010-08-18 22:15:35 | [diff] [blame] | 946 | </dt> | 
|  | 947 | <dd> | 
|  | 948 | <p> | 
|  | 949 | Creates the branch <new_branch> and start it at <start_point>; | 
|  | 950 | if it already exists, then reset it to <start_point>. This is | 
|  | 951 | equivalent to running "git branch" with "-f"; see | 
| Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 952 | <a href="git-branch.html">git-branch(1)</a> for details. | 
| Junio C Hamano | 619596a | 2010-08-18 22:15:35 | [diff] [blame] | 953 | </p> | 
|  | 954 | </dd> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 955 | <dt class="hdlist1"> | 
| Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 956 | -t | 
|  | 957 | </dt> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 958 | <dt class="hdlist1"> | 
| Junio C Hamano | eb41599 | 2008-06-08 22:49:47 | [diff] [blame] | 959 | --track | 
| Junio C Hamano | 103ad7f | 2007-03-14 11:19:26 | [diff] [blame] | 960 | </dt> | 
|  | 961 | <dd> | 
|  | 962 | <p> | 
| Junio C Hamano | 3bd66e9 | 2009-04-18 06:17:56 | [diff] [blame] | 963 | When creating a new branch, set up "upstream" configuration. See | 
| Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 964 | "--track" in <a href="git-branch.html">git-branch(1)</a> for details. | 
| Junio C Hamano | 103ad7f | 2007-03-14 11:19:26 | [diff] [blame] | 965 | </p> | 
| Junio C Hamano | 92d8037 | 2016-07-13 22:00:05 | [diff] [blame] | 966 | <div class="paragraph"><p>If no <code>-b</code> option is given, the name of the new branch will be | 
| Junio C Hamano | c710296 | 2013-05-29 23:57:17 | [diff] [blame] | 967 | derived from the remote-tracking branch, by looking at the local part of | 
|  | 968 | the refspec configured for the corresponding remote, and then stripping | 
|  | 969 | the initial part up to the "*". | 
| Junio C Hamano | 043628e | 2008-08-24 03:34:11 | [diff] [blame] | 970 | This would tell us to use "hack" as the local branch when branching | 
|  | 971 | off of "origin/hack" (or "remotes/origin/hack", or even | 
|  | 972 | "refs/remotes/origin/hack"). If the given name has no slash, or the above | 
|  | 973 | guessing results in an empty name, the guessing is aborted. You can | 
| Junio C Hamano | 92d8037 | 2016-07-13 22:00:05 | [diff] [blame] | 974 | explicitly give a name with <code>-b</code> in such a case.</p></div> | 
| Junio C Hamano | 103ad7f | 2007-03-14 11:19:26 | [diff] [blame] | 975 | </dd> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 976 | <dt class="hdlist1"> | 
| Junio C Hamano | 103ad7f | 2007-03-14 11:19:26 | [diff] [blame] | 977 | --no-track | 
|  | 978 | </dt> | 
|  | 979 | <dd> | 
|  | 980 | <p> | 
| Junio C Hamano | 3bd66e9 | 2009-04-18 06:17:56 | [diff] [blame] | 981 | Do not set up "upstream" configuration, even if the | 
| Junio C Hamano | 322c624 | 2015-03-23 21:32:46 | [diff] [blame] | 982 | branch.autoSetupMerge configuration variable is true. | 
| Junio C Hamano | 103ad7f | 2007-03-14 11:19:26 | [diff] [blame] | 983 | </p> | 
|  | 984 | </dd> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 985 | <dt class="hdlist1"> | 
| Junio C Hamano | 341071d | 2006-06-04 07:24:48 | [diff] [blame] | 986 | -l | 
|  | 987 | </dt> | 
|  | 988 | <dd> | 
|  | 989 | <p> | 
| Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 990 | Create the new branch’s reflog; see <a href="git-branch.html">git-branch(1)</a> for | 
| Junio C Hamano | 3bd66e9 | 2009-04-18 06:17:56 | [diff] [blame] | 991 | details. | 
| Junio C Hamano | 341071d | 2006-06-04 07:24:48 | [diff] [blame] | 992 | </p> | 
|  | 993 | </dd> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 994 | <dt class="hdlist1"> | 
| Junio C Hamano | 63c2bc9 | 2011-02-28 06:41:28 | [diff] [blame] | 995 | --detach | 
|  | 996 | </dt> | 
|  | 997 | <dd> | 
|  | 998 | <p> | 
|  | 999 | Rather than checking out a branch to work on it, check out a | 
|  | 1000 | commit for inspection and discardable experiments. | 
|  | 1001 | This is the default behavior of "git checkout <commit>" when | 
|  | 1002 | <commit> is not a branch name. See the "DETACHED HEAD" section | 
|  | 1003 | below for details. | 
|  | 1004 | </p> | 
|  | 1005 | </dd> | 
|  | 1006 | <dt class="hdlist1"> | 
| Junio C Hamano | eccdd4a | 2012-09-10 23:28:17 | [diff] [blame] | 1007 | --orphan <new_branch> | 
| Junio C Hamano | cc7636a | 2010-05-21 14:57:53 | [diff] [blame] | 1008 | </dt> | 
|  | 1009 | <dd> | 
|  | 1010 | <p> | 
| Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 1011 | Create a new <em>orphan</em> branch, named <new_branch>, started from | 
|  | 1012 | <start_point> and switch to it. The first commit made on this | 
|  | 1013 | new branch will have no parents and it will be the root of a new | 
|  | 1014 | history totally disconnected from all the other branches and | 
|  | 1015 | commits. | 
| Junio C Hamano | cc7636a | 2010-05-21 14:57:53 | [diff] [blame] | 1016 | </p> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1017 | <div class="paragraph"><p>The index and the working tree are adjusted as if you had previously run | 
| Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 1018 | "git checkout <start_point>". This allows you to start a new history | 
|  | 1019 | that records a set of paths similar to <start_point> by easily running | 
|  | 1020 | "git commit -a" to make the root commit.</p></div> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1021 | <div class="paragraph"><p>This can be useful when you want to publish the tree from a commit | 
| Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 1022 | without exposing its full history. You might want to do this to publish | 
|  | 1023 | an open source branch of a project whose current tree is "clean", but | 
|  | 1024 | whose full history contains proprietary or otherwise encumbered bits of | 
|  | 1025 | code.</p></div> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1026 | <div class="paragraph"><p>If you want to start a disconnected history that records a set of paths | 
| Junio C Hamano | bb88cf4 | 2010-06-21 15:23:55 | [diff] [blame] | 1027 | that is totally different from the one of <start_point>, then you should | 
|  | 1028 | clear the index and the working tree right after creating the orphan | 
|  | 1029 | branch by running "git rm -rf ." from the top level of the working tree. | 
|  | 1030 | Afterwards you will be ready to prepare your new files, repopulating the | 
|  | 1031 | working tree, by copying them from elsewhere, extracting a tarball, etc.</p></div> | 
| Junio C Hamano | cc7636a | 2010-05-21 14:57:53 | [diff] [blame] | 1032 | </dd> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1033 | <dt class="hdlist1"> | 
| Junio C Hamano | c79bc67 | 2013-04-22 19:12:47 | [diff] [blame] | 1034 | --ignore-skip-worktree-bits | 
|  | 1035 | </dt> | 
|  | 1036 | <dd> | 
|  | 1037 | <p> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1038 | In sparse checkout mode, <code>git checkout -- <paths></code> would | 
| Junio C Hamano | c79bc67 | 2013-04-22 19:12:47 | [diff] [blame] | 1039 | update only entries matched by <paths> and sparse patterns | 
|  | 1040 | in $GIT_DIR/info/sparse-checkout. This option ignores | 
|  | 1041 | the sparse patterns and adds back any files in <paths>. | 
|  | 1042 | </p> | 
|  | 1043 | </dd> | 
|  | 1044 | <dt class="hdlist1"> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1045 | -m | 
|  | 1046 | </dt> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1047 | <dt class="hdlist1"> | 
| Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 1048 | --merge | 
|  | 1049 | </dt> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1050 | <dd> | 
|  | 1051 | <p> | 
| Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 1052 | When switching branches, | 
|  | 1053 | if you have local modifications to one or more files that | 
| Junio C Hamano | 2b13527 | 2006-03-18 07:45:42 | [diff] [blame] | 1054 | are different between the current branch and the branch to | 
|  | 1055 | which you are switching, the command refuses to switch | 
|  | 1056 | branches in order to preserve your modifications in context. | 
|  | 1057 | However, with this option, a three-way merge between the current | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1058 | branch, your working tree contents, and the new branch | 
|  | 1059 | is done, and you will be on the new branch. | 
|  | 1060 | </p> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1061 | <div class="paragraph"><p>When a merge conflict happens, the index entries for conflicting | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1062 | paths are left unmerged, and you need to resolve the conflicts | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1063 | and mark the resolved paths with <code>git add</code> (or <code>git rm</code> if the merge | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1064 | should result in deletion of the path).</p></div> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1065 | <div class="paragraph"><p>When checking out paths from the index, this option lets you recreate | 
| Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 1066 | the conflicted merge in the specified paths.</p></div> | 
|  | 1067 | </dd> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1068 | <dt class="hdlist1"> | 
| Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 1069 | --conflict=<style> | 
|  | 1070 | </dt> | 
|  | 1071 | <dd> | 
|  | 1072 | <p> | 
|  | 1073 | The same as --merge option above, but changes the way the | 
|  | 1074 | conflicting hunks are presented, overriding the | 
| Junio C Hamano | 322c624 | 2015-03-23 21:32:46 | [diff] [blame] | 1075 | merge.conflictStyle configuration variable. Possible values are | 
| Junio C Hamano | a476efa | 2008-10-10 15:31:42 | [diff] [blame] | 1076 | "merge" (default) and "diff3" (in addition to what is shown by | 
|  | 1077 | "merge" style, shows the original contents). | 
|  | 1078 | </p> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1079 | </dd> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1080 | <dt class="hdlist1"> | 
| Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 1081 | -p | 
|  | 1082 | </dt> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1083 | <dt class="hdlist1"> | 
| Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 1084 | --patch | 
|  | 1085 | </dt> | 
|  | 1086 | <dd> | 
|  | 1087 | <p> | 
|  | 1088 | Interactively select hunks in the difference between the | 
|  | 1089 | <tree-ish> (or the index, if unspecified) and the working | 
|  | 1090 | tree. The chosen hunks are then applied in reverse to the | 
|  | 1091 | working tree (and if a <tree-ish> was specified, the index). | 
|  | 1092 | </p> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1093 | <div class="paragraph"><p>This means that you can use <code>git checkout -p</code> to selectively discard | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1094 | edits from your current working tree. See the “Interactive Mode” | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1095 | section of <a href="git-add.html">git-add(1)</a> to learn how to operate the <code>--patch</code> mode.</p></div> | 
| Junio C Hamano | c28068f | 2009-09-08 00:55:23 | [diff] [blame] | 1096 | </dd> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1097 | <dt class="hdlist1"> | 
| Junio C Hamano | 4cc4a84 | 2015-05-11 22:41:02 | [diff] [blame] | 1098 | --ignore-other-worktrees | 
|  | 1099 | </dt> | 
|  | 1100 | <dd> | 
|  | 1101 | <p> | 
|  | 1102 | <code>git checkout</code> refuses when the wanted ref is already checked | 
|  | 1103 | out by another worktree. This option makes it check the ref | 
|  | 1104 | out anyway. In other words, the ref can be held by more than one | 
|  | 1105 | worktree. | 
|  | 1106 | </p> | 
|  | 1107 | </dd> | 
|  | 1108 | <dt class="hdlist1"> | 
| Junio C Hamano | 2affb96 | 2017-03-28 22:01:40 | [diff] [blame] | 1109 | --[no-]recurse-submodules | 
|  | 1110 | </dt> | 
|  | 1111 | <dd> | 
|  | 1112 | <p> | 
|  | 1113 | Using --recurse-submodules will update the content of all initialized | 
|  | 1114 | submodules according to the commit recorded in the superproject. If | 
|  | 1115 | local modifications in a submodule would be overwritten the checkout | 
|  | 1116 | will fail unless <code>-f</code> is used. If nothing (or --no-recurse-submodules) | 
|  | 1117 | is used, the work trees of submodules will not be updated. | 
| Junio C Hamano | 912712b | 2017-12-06 18:04:01 | [diff] [blame] | 1118 | Just like <a href="git-submodule.html">git-submodule(1)</a>, this will detach the | 
|  | 1119 | submodules HEAD. | 
| Junio C Hamano | 2affb96 | 2017-03-28 22:01:40 | [diff] [blame] | 1120 | </p> | 
|  | 1121 | </dd> | 
|  | 1122 | <dt class="hdlist1"> | 
| Junio C Hamano | 3bd66e9 | 2009-04-18 06:17:56 | [diff] [blame] | 1123 | <branch> | 
|  | 1124 | </dt> | 
|  | 1125 | <dd> | 
|  | 1126 | <p> | 
|  | 1127 | Branch to checkout; if it refers to a branch (i.e., a name that, | 
|  | 1128 | when prepended with "refs/heads/", is a valid ref), then that | 
|  | 1129 | branch is checked out. Otherwise, if it refers to a valid | 
|  | 1130 | commit, your HEAD becomes "detached" and you are no longer on | 
|  | 1131 | any branch (see below for details). | 
|  | 1132 | </p> | 
| Junio C Hamano | 371470a | 2017-12-13 22:26:40 | [diff] [blame] | 1133 | <div class="paragraph"><p>You can use the <code>"@{-N}"</code> syntax to refer to the N-th last | 
|  | 1134 | branch/commit checked out using "git checkout" operation. You may | 
|  | 1135 | also specify <code>-</code> which is synonymous to <code>"@{-1}</code>.</p></div> | 
|  | 1136 | <div class="paragraph"><p>As a special case, you may use <code>"A...B"</code> as a shortcut for the | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1137 | merge base of <code>A</code> and <code>B</code> if there is exactly one merge base. You can | 
|  | 1138 | leave out at most one of <code>A</code> and <code>B</code>, in which case it defaults to <code>HEAD</code>.</p></div> | 
| Junio C Hamano | 3bd66e9 | 2009-04-18 06:17:56 | [diff] [blame] | 1139 | </dd> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1140 | <dt class="hdlist1"> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1141 | <new_branch> | 
|  | 1142 | </dt> | 
|  | 1143 | <dd> | 
|  | 1144 | <p> | 
|  | 1145 | Name for the new branch. | 
|  | 1146 | </p> | 
|  | 1147 | </dd> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1148 | <dt class="hdlist1"> | 
| Junio C Hamano | 3bd66e9 | 2009-04-18 06:17:56 | [diff] [blame] | 1149 | <start_point> | 
|  | 1150 | </dt> | 
|  | 1151 | <dd> | 
|  | 1152 | <p> | 
|  | 1153 | The name of a commit at which to start the new branch; see | 
| Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 1154 | <a href="git-branch.html">git-branch(1)</a> for details. Defaults to HEAD. | 
| Junio C Hamano | 3bd66e9 | 2009-04-18 06:17:56 | [diff] [blame] | 1155 | </p> | 
|  | 1156 | </dd> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1157 | <dt class="hdlist1"> | 
| Junio C Hamano | b4a9ede | 2009-04-08 07:36:32 | [diff] [blame] | 1158 | <tree-ish> | 
|  | 1159 | </dt> | 
|  | 1160 | <dd> | 
|  | 1161 | <p> | 
|  | 1162 | Tree to checkout from (when paths are given). If not specified, | 
|  | 1163 | the index will be used. | 
|  | 1164 | </p> | 
|  | 1165 | </dd> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1166 | </dl></div> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1167 | </div> | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1168 | </div> | 
|  | 1169 | <div class="sect1"> | 
| Junio C Hamano | 63c2bc9 | 2011-02-28 06:41:28 | [diff] [blame] | 1170 | <h2 id="_detached_head">DETACHED HEAD</h2> | 
| Junio C Hamano | 4f9a605 | 2007-01-17 20:25:16 | [diff] [blame] | 1171 | <div class="sectionbody"> | 
| Junio C Hamano | 63c2bc9 | 2011-02-28 06:41:28 | [diff] [blame] | 1172 | <div class="paragraph"><p>HEAD normally refers to a named branch (e.g. <em>master</em>). Meanwhile, each | 
|  | 1173 | branch refers to a specific commit. Let’s look at a repo with three | 
|  | 1174 | commits, one of them tagged, and with branch <em>master</em> checked out:</p></div> | 
| Junio C Hamano | 4f9a605 | 2007-01-17 20:25:16 | [diff] [blame] | 1175 | <div class="listingblock"> | 
|  | 1176 | <div class="content"> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1177 | <pre><code> HEAD (refers to branch 'master') | 
| Junio C Hamano | 63c2bc9 | 2011-02-28 06:41:28 | [diff] [blame] | 1178 | | | 
|  | 1179 | v | 
|  | 1180 | a---b---c branch 'master' (refers to commit 'c') | 
|  | 1181 | ^ | 
|  | 1182 | | | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1183 | tag 'v2.0' (refers to commit 'b')</code></pre> | 
| Junio C Hamano | 4f9a605 | 2007-01-17 20:25:16 | [diff] [blame] | 1184 | </div></div> | 
| Junio C Hamano | 63c2bc9 | 2011-02-28 06:41:28 | [diff] [blame] | 1185 | <div class="paragraph"><p>When a commit is created in this state, the branch is updated to refer to | 
|  | 1186 | the new commit. Specifically, <em>git commit</em> creates a new commit <em>d</em>, whose | 
|  | 1187 | parent is commit <em>c</em>, and then updates branch <em>master</em> to refer to new | 
|  | 1188 | commit <em>d</em>. HEAD still refers to branch <em>master</em> and so indirectly now refers | 
|  | 1189 | to commit <em>d</em>:</p></div> | 
| Junio C Hamano | 9d52e57 | 2007-02-13 23:48:20 | [diff] [blame] | 1190 | <div class="listingblock"> | 
|  | 1191 | <div class="content"> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1192 | <pre><code>$ edit; git add; git commit | 
| Junio C Hamano | 63c2bc9 | 2011-02-28 06:41:28 | [diff] [blame] | 1193 |  | 
|  | 1194 | HEAD (refers to branch 'master') | 
|  | 1195 | | | 
|  | 1196 | v | 
|  | 1197 | a---b---c---d branch 'master' (refers to commit 'd') | 
|  | 1198 | ^ | 
|  | 1199 | | | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1200 | tag 'v2.0' (refers to commit 'b')</code></pre> | 
| Junio C Hamano | 63c2bc9 | 2011-02-28 06:41:28 | [diff] [blame] | 1201 | </div></div> | 
|  | 1202 | <div class="paragraph"><p>It is sometimes useful to be able to checkout a commit that is not at | 
|  | 1203 | the tip of any named branch, or even to create a new commit that is not | 
|  | 1204 | referenced by a named branch. Let’s look at what happens when we | 
|  | 1205 | checkout commit <em>b</em> (here we show two ways this may be done):</p></div> | 
|  | 1206 | <div class="listingblock"> | 
|  | 1207 | <div class="content"> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1208 | <pre><code>$ git checkout v2.0 # or | 
| Junio C Hamano | 63c2bc9 | 2011-02-28 06:41:28 | [diff] [blame] | 1209 | $ git checkout master^^ | 
|  | 1210 |  | 
|  | 1211 | HEAD (refers to commit 'b') | 
|  | 1212 | | | 
|  | 1213 | v | 
|  | 1214 | a---b---c---d branch 'master' (refers to commit 'd') | 
|  | 1215 | ^ | 
|  | 1216 | | | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1217 | tag 'v2.0' (refers to commit 'b')</code></pre> | 
| Junio C Hamano | 63c2bc9 | 2011-02-28 06:41:28 | [diff] [blame] | 1218 | </div></div> | 
|  | 1219 | <div class="paragraph"><p>Notice that regardless of which checkout command we use, HEAD now refers | 
|  | 1220 | directly to commit <em>b</em>. This is known as being in detached HEAD state. | 
|  | 1221 | It means simply that HEAD refers to a specific commit, as opposed to | 
|  | 1222 | referring to a named branch. Let’s see what happens when we create a commit:</p></div> | 
|  | 1223 | <div class="listingblock"> | 
|  | 1224 | <div class="content"> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1225 | <pre><code>$ edit; git add; git commit | 
| Junio C Hamano | 63c2bc9 | 2011-02-28 06:41:28 | [diff] [blame] | 1226 |  | 
|  | 1227 | HEAD (refers to commit 'e') | 
|  | 1228 | | | 
|  | 1229 | v | 
|  | 1230 | e | 
|  | 1231 | / | 
|  | 1232 | a---b---c---d branch 'master' (refers to commit 'd') | 
|  | 1233 | ^ | 
|  | 1234 | | | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1235 | tag 'v2.0' (refers to commit 'b')</code></pre> | 
| Junio C Hamano | 63c2bc9 | 2011-02-28 06:41:28 | [diff] [blame] | 1236 | </div></div> | 
|  | 1237 | <div class="paragraph"><p>There is now a new commit <em>e</em>, but it is referenced only by HEAD. We can | 
|  | 1238 | of course add yet another commit in this state:</p></div> | 
|  | 1239 | <div class="listingblock"> | 
|  | 1240 | <div class="content"> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1241 | <pre><code>$ edit; git add; git commit | 
| Junio C Hamano | 63c2bc9 | 2011-02-28 06:41:28 | [diff] [blame] | 1242 |  | 
|  | 1243 | HEAD (refers to commit 'f') | 
|  | 1244 | | | 
|  | 1245 | v | 
|  | 1246 | e---f | 
|  | 1247 | / | 
|  | 1248 | a---b---c---d branch 'master' (refers to commit 'd') | 
|  | 1249 | ^ | 
|  | 1250 | | | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1251 | tag 'v2.0' (refers to commit 'b')</code></pre> | 
| Junio C Hamano | 63c2bc9 | 2011-02-28 06:41:28 | [diff] [blame] | 1252 | </div></div> | 
| Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1253 | <div class="paragraph"><p>In fact, we can perform all the normal Git operations. But, let’s look | 
| Junio C Hamano | 63c2bc9 | 2011-02-28 06:41:28 | [diff] [blame] | 1254 | at what happens when we then checkout master:</p></div> | 
|  | 1255 | <div class="listingblock"> | 
|  | 1256 | <div class="content"> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1257 | <pre><code>$ git checkout master | 
| Junio C Hamano | 63c2bc9 | 2011-02-28 06:41:28 | [diff] [blame] | 1258 |  | 
|  | 1259 | HEAD (refers to branch 'master') | 
|  | 1260 | e---f | | 
|  | 1261 | / v | 
|  | 1262 | a---b---c---d branch 'master' (refers to commit 'd') | 
|  | 1263 | ^ | 
|  | 1264 | | | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1265 | tag 'v2.0' (refers to commit 'b')</code></pre> | 
| Junio C Hamano | 63c2bc9 | 2011-02-28 06:41:28 | [diff] [blame] | 1266 | </div></div> | 
|  | 1267 | <div class="paragraph"><p>It is important to realize that at this point nothing refers to commit | 
|  | 1268 | <em>f</em>. Eventually commit <em>f</em> (and by extension commit <em>e</em>) will be deleted | 
| Junio C Hamano | 076ffcc | 2013-02-06 05:13:21 | [diff] [blame] | 1269 | by the routine Git garbage collection process, unless we create a reference | 
| Junio C Hamano | 63c2bc9 | 2011-02-28 06:41:28 | [diff] [blame] | 1270 | before that happens. If we have not yet moved away from commit <em>f</em>, | 
|  | 1271 | any of these will create a reference to it:</p></div> | 
|  | 1272 | <div class="listingblock"> | 
|  | 1273 | <div class="content"> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1274 | <pre><code>$ git checkout -b foo <b><1></b> | 
| Junio C Hamano | 63c2bc9 | 2011-02-28 06:41:28 | [diff] [blame] | 1275 | $ git branch foo <b><2></b> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1276 | $ git tag foo <b><3></b></code></pre> | 
| Junio C Hamano | 63c2bc9 | 2011-02-28 06:41:28 | [diff] [blame] | 1277 | </div></div> | 
|  | 1278 | <div class="colist arabic"><ol> | 
|  | 1279 | <li> | 
|  | 1280 | <p> | 
|  | 1281 | creates a new branch <em>foo</em>, which refers to commit <em>f</em>, and then | 
|  | 1282 | updates HEAD to refer to branch <em>foo</em>. In other words, we’ll no longer | 
|  | 1283 | be in detached HEAD state after this command. | 
|  | 1284 | </p> | 
|  | 1285 | </li> | 
|  | 1286 | <li> | 
|  | 1287 | <p> | 
|  | 1288 | similarly creates a new branch <em>foo</em>, which refers to commit <em>f</em>, | 
|  | 1289 | but leaves HEAD detached. | 
|  | 1290 | </p> | 
|  | 1291 | </li> | 
|  | 1292 | <li> | 
|  | 1293 | <p> | 
|  | 1294 | creates a new tag <em>foo</em>, which refers to commit <em>f</em>, | 
|  | 1295 | leaving HEAD detached. | 
|  | 1296 | </p> | 
|  | 1297 | </li> | 
|  | 1298 | </ol></div> | 
|  | 1299 | <div class="paragraph"><p>If we have moved away from commit <em>f</em>, then we must first recover its object | 
|  | 1300 | name (typically by using git reflog), and then we can create a reference to | 
|  | 1301 | it. For example, to see the last two commits to which HEAD referred, we | 
|  | 1302 | can use either of these commands:</p></div> | 
|  | 1303 | <div class="listingblock"> | 
|  | 1304 | <div class="content"> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1305 | <pre><code>$ git reflog -2 HEAD # or | 
|  | 1306 | $ git log -g -2 HEAD</code></pre> | 
| Junio C Hamano | 9d52e57 | 2007-02-13 23:48:20 | [diff] [blame] | 1307 | </div></div> | 
| Junio C Hamano | 4f9a605 | 2007-01-17 20:25:16 | [diff] [blame] | 1308 | </div> | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1309 | </div> | 
|  | 1310 | <div class="sect1"> | 
| Junio C Hamano | ad70bf0 | 2016-09-26 23:44:27 | [diff] [blame] | 1311 | <h2 id="_argument_disambiguation">ARGUMENT DISAMBIGUATION</h2> | 
|  | 1312 | <div class="sectionbody"> | 
|  | 1313 | <div class="paragraph"><p>When there is only one argument given and it is not <code>--</code> (e.g. "git | 
|  | 1314 | checkout abc"), and when the argument is both a valid <code><tree-ish></code> | 
|  | 1315 | (e.g. a branch "abc" exists) and a valid <code><pathspec></code> (e.g. a file | 
|  | 1316 | or a directory whose name is "abc" exists), Git would usually ask | 
|  | 1317 | you to disambiguate. Because checking out a branch is so common an | 
|  | 1318 | operation, however, "git checkout abc" takes "abc" as a <code><tree-ish></code> | 
|  | 1319 | in such a situation. Use <code>git checkout -- <pathspec></code> if you want | 
|  | 1320 | to checkout these paths out of the index.</p></div> | 
|  | 1321 | </div> | 
|  | 1322 | </div> | 
|  | 1323 | <div class="sect1"> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1324 | <h2 id="_examples">EXAMPLES</h2> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1325 | <div class="sectionbody"> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1326 | <div class="olist arabic"><ol class="arabic"> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1327 | <li> | 
|  | 1328 | <p> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1329 | The following sequence checks out the <code>master</code> branch, reverts | 
|  | 1330 | the <code>Makefile</code> to two revisions back, deletes hello.c by | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1331 | mistake, and gets it back from the index. | 
|  | 1332 | </p> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1333 | <div class="listingblock"> | 
|  | 1334 | <div class="content"> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1335 | <pre><code>$ git checkout master <b><1></b> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1336 | $ git checkout master~2 Makefile <b><2></b> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1337 | $ rm -f hello.c | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1338 | $ git checkout hello.c <b><3></b></code></pre> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1339 | </div></div> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1340 | <div class="colist arabic"><ol> | 
| Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1341 | <li> | 
|  | 1342 | <p> | 
|  | 1343 | switch branch | 
|  | 1344 | </p> | 
|  | 1345 | </li> | 
|  | 1346 | <li> | 
|  | 1347 | <p> | 
| Junio C Hamano | 5705393 | 2009-03-11 08:48:32 | [diff] [blame] | 1348 | take a file out of another commit | 
| Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1349 | </p> | 
|  | 1350 | </li> | 
|  | 1351 | <li> | 
|  | 1352 | <p> | 
| Junio C Hamano | b4a9ede | 2009-04-08 07:36:32 | [diff] [blame] | 1353 | restore hello.c from the index | 
| Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1354 | </p> | 
| Junio C Hamano | 693e709 | 2012-09-12 22:56:53 | [diff] [blame] | 1355 | <div class="paragraph"><p>If you want to check out <em>all</em> C source files out of the index, | 
|  | 1356 | you can say</p></div> | 
|  | 1357 | <div class="listingblock"> | 
|  | 1358 | <div class="content"> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1359 | <pre><code>$ git checkout -- '*.c'</code></pre> | 
| Junio C Hamano | 693e709 | 2012-09-12 22:56:53 | [diff] [blame] | 1360 | </div></div> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1361 | <div class="paragraph"><p>Note the quotes around <code>*.c</code>. The file <code>hello.c</code> will also be | 
| Junio C Hamano | 693e709 | 2012-09-12 22:56:53 | [diff] [blame] | 1362 | checked out, even though it is no longer in the working tree, | 
|  | 1363 | because the file globbing is used to match entries in the index | 
|  | 1364 | (not in the working tree by the shell).</p></div> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1365 | <div class="paragraph"><p>If you have an unfortunate branch that is named <code>hello.c</code>, this | 
| Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1366 | step would be confused as an instruction to switch to that branch. | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1367 | You should instead write:</p></div> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1368 | <div class="listingblock"> | 
|  | 1369 | <div class="content"> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1370 | <pre><code>$ git checkout -- hello.c</code></pre> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1371 | </div></div> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1372 | </li> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1373 | </ol></div> | 
| Junio C Hamano | c8d88c2 | 2006-04-29 07:02:01 | [diff] [blame] | 1374 | </li> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1375 | <li> | 
|  | 1376 | <p> | 
| Junio C Hamano | 5705393 | 2009-03-11 08:48:32 | [diff] [blame] | 1377 | After working in the wrong branch, switching to the correct | 
| Junio C Hamano | 2b13527 | 2006-03-18 07:45:42 | [diff] [blame] | 1378 | branch would be done using: | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1379 | </p> | 
|  | 1380 | <div class="listingblock"> | 
|  | 1381 | <div class="content"> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1382 | <pre><code>$ git checkout mytopic</code></pre> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1383 | </div></div> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1384 | <div class="paragraph"><p>However, your "wrong" branch and correct "mytopic" branch may | 
| Junio C Hamano | 5705393 | 2009-03-11 08:48:32 | [diff] [blame] | 1385 | differ in files that you have modified locally, in which case | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1386 | the above checkout would fail like this:</p></div> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1387 | <div class="listingblock"> | 
|  | 1388 | <div class="content"> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1389 | <pre><code>$ git checkout mytopic | 
|  | 1390 | error: You have local changes to 'frotz'; not switching branches.</code></pre> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1391 | </div></div> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1392 | <div class="paragraph"><p>You can give the <code>-m</code> flag to the command, which would try a | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1393 | three-way merge:</p></div> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1394 | <div class="listingblock"> | 
|  | 1395 | <div class="content"> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1396 | <pre><code>$ git checkout -m mytopic | 
|  | 1397 | Auto-merging frotz</code></pre> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1398 | </div></div> | 
| Junio C Hamano | 97bcb48 | 2010-11-25 03:16:07 | [diff] [blame] | 1399 | <div class="paragraph"><p>After this three-way merge, the local modifications are <em>not</em> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1400 | registered in your index file, so <code>git diff</code> would show you what | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1401 | changes you made since the tip of the new branch.</p></div> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1402 | </li> | 
|  | 1403 | <li> | 
|  | 1404 | <p> | 
|  | 1405 | When a merge conflict happens during switching branches with | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1406 | the <code>-m</code> option, you would see something like this: | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1407 | </p> | 
|  | 1408 | <div class="listingblock"> | 
|  | 1409 | <div class="content"> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1410 | <pre><code>$ git checkout -m mytopic | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1411 | Auto-merging frotz | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1412 | ERROR: Merge conflict in frotz | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1413 | fatal: merge program failed</code></pre> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1414 | </div></div> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1415 | <div class="paragraph"><p>At this point, <code>git diff</code> shows the changes cleanly merged as in | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1416 | the previous example, as well as the changes in the conflicted | 
|  | 1417 | files. Edit and resolve the conflict and mark it resolved with | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1418 | <code>git add</code> as usual:</p></div> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1419 | <div class="listingblock"> | 
|  | 1420 | <div class="content"> | 
| Junio C Hamano | c14e6ad | 2014-10-31 20:25:53 | [diff] [blame] | 1421 | <pre><code>$ edit frotz | 
|  | 1422 | $ git add frotz</code></pre> | 
| Junio C Hamano | 74e8a2d | 2006-01-14 03:58:41 | [diff] [blame] | 1423 | </div></div> | 
|  | 1424 | </li> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1425 | </ol></div> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1426 | </div> | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1427 | </div> | 
|  | 1428 | <div class="sect1"> | 
| Junio C Hamano | ba4b928 | 2008-07-06 05:20:31 | [diff] [blame] | 1429 | <h2 id="_git">GIT</h2> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1430 | <div class="sectionbody"> | 
| Junio C Hamano | a28a920 | 2012-06-21 07:08:23 | [diff] [blame] | 1431 | <div class="paragraph"><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] | 1432 | </div> | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 1433 | </div> | 
| Junio C Hamano | 9d97115 | 2012-12-19 00:43:11 | [diff] [blame] | 1434 | </div> | 
| Junio C Hamano | 7bd050f | 2011-09-22 06:32:22 | [diff] [blame] | 1435 | <div id="footnotes"><hr /></div> | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1436 | <div id="footer"> | 
|  | 1437 | <div id="footer-text"> | 
| Junio C Hamano | 2ef0ba3 | 2018-01-26 23:13:53 | [diff] [blame] | 1438 | Last updated | 
|  | 1439 | 2018-01-26 15:11:04 PST | 
| Junio C Hamano | 1a4e841 | 2005-12-27 08:17:23 | [diff] [blame] | 1440 | </div> | 
|  | 1441 | </div> | 
|  | 1442 | </body> | 
|  | 1443 | </html> |