|
30 | 30 | <script src="site_libs/font-awesome-5.0.13/js/fa-v4-shims.min.js"></script> |
31 | 31 |
|
32 | 32 |
|
| 33 | +<style type="text/css">code{white-space: pre;}</style> |
| 34 | +<style type="text/css"> |
| 35 | +div.sourceCode { overflow-x: auto; } |
| 36 | +table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode { |
| 37 | + margin: 0; padding: 0; vertical-align: baseline; border: none; } |
| 38 | +table.sourceCode { width: 100%; line-height: 100%; background-color: #f8f8f8; } |
| 39 | +td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; } |
| 40 | +td.sourceCode { padding-left: 5px; } |
| 41 | +pre, code { background-color: #f8f8f8; } |
| 42 | +code > span.kw { color: #204a87; font-weight: bold; } /* Keyword */ |
| 43 | +code > span.dt { color: #204a87; } /* DataType */ |
| 44 | +code > span.dv { color: #0000cf; } /* DecVal */ |
| 45 | +code > span.bn { color: #0000cf; } /* BaseN */ |
| 46 | +code > span.fl { color: #0000cf; } /* Float */ |
| 47 | +code > span.ch { color: #4e9a06; } /* Char */ |
| 48 | +code > span.st { color: #4e9a06; } /* String */ |
| 49 | +code > span.co { color: #8f5902; font-style: italic; } /* Comment */ |
| 50 | +code > span.ot { color: #8f5902; } /* Other */ |
| 51 | +code > span.al { color: #ef2929; } /* Alert */ |
| 52 | +code > span.fu { color: #000000; } /* Function */ |
| 53 | +code > span.er { color: #a40000; font-weight: bold; } /* Error */ |
| 54 | +code > span.wa { color: #8f5902; font-weight: bold; font-style: italic; } /* Warning */ |
| 55 | +code > span.cn { color: #000000; } /* Constant */ |
| 56 | +code > span.sc { color: #000000; } /* SpecialChar */ |
| 57 | +code > span.vs { color: #4e9a06; } /* VerbatimString */ |
| 58 | +code > span.ss { color: #4e9a06; } /* SpecialString */ |
| 59 | +code > span.im { } /* Import */ |
| 60 | +code > span.va { color: #000000; } /* Variable */ |
| 61 | +code > span.cf { color: #204a87; font-weight: bold; } /* ControlFlow */ |
| 62 | +code > span.op { color: #ce5c00; font-weight: bold; } /* Operator */ |
| 63 | +code > span.pp { color: #8f5902; font-style: italic; } /* Preprocessor */ |
| 64 | +code > span.ex { } /* Extension */ |
| 65 | +code > span.at { color: #c4a000; } /* Attribute */ |
| 66 | +code > span.do { color: #8f5902; font-weight: bold; font-style: italic; } /* Documentation */ |
| 67 | +code > span.an { color: #8f5902; font-weight: bold; font-style: italic; } /* Annotation */ |
| 68 | +code > span.cv { color: #8f5902; font-weight: bold; font-style: italic; } /* CommentVar */ |
| 69 | +code > span.in { color: #8f5902; font-weight: bold; font-style: italic; } /* Information */ |
| 70 | +</style> |
| 71 | +<style type="text/css"> |
| 72 | + pre:not([class]) { |
| 73 | + background-color: white; |
| 74 | + } |
| 75 | +</style> |
33 | 76 |
|
34 | 77 |
|
35 | 78 | <style type="text/css"> |
@@ -323,21 +366,91 @@ <h1 class="title toc-ignore">Git: Branch / Merge / Revert</h1> |
323 | 366 | </div> |
324 | 367 |
|
325 | 368 |
|
| 369 | +<p>This document follows set-up from the <a href="handson.html">previous document</a></p> |
| 370 | +<div id="standard-edit" class="section level2"> |
| 371 | +<h2>Standard Edit</h2> |
| 372 | +<ul> |
| 373 | +<li>Add your name and a bulleted list with three of your favorite foods</li> |
| 374 | +<li>Commit your changes</li> |
| 375 | +</ul> |
| 376 | +</div> |
| 377 | +<div id="branch" class="section level2"> |
| 378 | +<h2>Branch</h2> |
326 | 379 | <ol style="list-style-type: decimal"> |
327 | | -<li>Make Branch “version2” |
328 | | -<ol style="list-style-type: decimal"> |
329 | | -<li>checkout version2</li> |
330 | | -<li>Add stuff (todo.md)</li> |
331 | | -</ol></li> |
332 | | -<li>Checkout Main Branch |
333 | | -<ol style="list-style-type: decimal"> |
334 | | -<li>update README.Rmd</li> |
335 | | -<li>Look at the various tracks</li> |
336 | | -</ol></li> |
337 | | -<li>Merge.</li> |
338 | | -<li>Conflict</li> |
339 | | -<li>Revert</li> |
| 380 | +<li><p>Create a branch <em>version2</em></p> |
| 381 | +<ul> |
| 382 | +<li>The funny icon is used to <strong>create</strong> and <strong>checkout</strong> a branch</li> |
| 383 | +<li>By clicking <strong>Create</strong>, <code>git checkout <<branch-name>></code> is invoked</li> |
| 384 | +<li>Create a new text that lists 3 favorite movies save it as <code>movies.md</code></li> |
| 385 | +<li>Commit your changes</li> |
| 386 | +</ul></li> |
| 387 | +</ol> |
| 388 | +<p><img src="images/branch_create.png" style="display: block; margin: auto;" /></p> |
| 389 | +<ol start="2" style="list-style-type: decimal"> |
| 390 | +<li><p>Checkout the <em>master</em> branch</p> |
| 391 | +<ul> |
| 392 | +<li>Watch the <strong>Files</strong> tab as you switch back to the <em>master</em> branch. Where is the <code>movies.md</code> file?</li> |
| 393 | +</ul></li> |
| 394 | +</ol> |
| 395 | +<p><img src="images/branch_checkout.png" style="display: block; margin: auto;" /></p> |
| 396 | +<ol start="3" style="list-style-type: decimal"> |
| 397 | +<li><p>Checkout the <em>version2</em> branch again</p> |
| 398 | +<ul> |
| 399 | +<li>Edit the README.md file by adding 3 of your favorite books</li> |
| 400 | +<li>Commit your changes</li> |
| 401 | +<li>Push your changes</li> |
| 402 | +</ul></li> |
| 403 | +<li><p>Observe the visual representations of the branching and updating. <<Git - Clock>> -OR- GitHub > Settings > Insights > Network</p></li> |
340 | 404 | </ol> |
| 405 | +</div> |
| 406 | +<div id="merge" class="section level2"> |
| 407 | +<h2>Merge</h2> |
| 408 | +<ol start="5" style="list-style-type: decimal"> |
| 409 | +<li><p>Checkout the <em>master</em> branch</p> |
| 410 | +<ul> |
| 411 | +<li>In the Terminal window type: <code>git merge version2</code></li> |
| 412 | +<li>You should see a terminal response similar to below…</li> |
| 413 | +<li>Then, Push your changes</li> |
| 414 | +</ul></li> |
| 415 | +</ol> |
| 416 | +<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="ex">Updating</span> 83fb5bb..08c9267 |
| 417 | +<span class="ex">Fast-forward</span> |
| 418 | + <span class="ex">README.md</span> <span class="kw">|</span> <span class="ex">8</span> +++++++- |
| 419 | + <span class="ex">movies.md</span> <span class="kw">|</span> <span class="ex">5</span> +++++ |
| 420 | + <span class="ex">2</span> files changed, 12 insertions(+), <span class="ex">1</span> deletion(-) |
| 421 | + <span class="ex">create</span> mode 100644 movies.md</code></pre></div> |
| 422 | +<ol start="6" style="list-style-type: decimal"> |
| 423 | +<li>Observe the visual representations of the version history</li> |
| 424 | +</ol> |
| 425 | +</div> |
| 426 | +<div id="conflict" class="section level2"> |
| 427 | +<h2>Conflict</h2> |
| 428 | +<ol start="7" style="list-style-type: decimal"> |
| 429 | +<li>Edit README.md in <em>master</em> by changing your name. Commit then Push.</li> |
| 430 | +<li>Edit README.md in <em>version2</em> by changing the name to something different from the step above. Commit then Push.</li> |
| 431 | +<li>Checkout <em>master</em>, then <code>git merge version2</code></li> |
| 432 | +<li>Fix Conflicts, then Save. ; Commit and Push.</li> |
| 433 | +</ol> |
| 434 | +</div> |
| 435 | +<div id="revert" class="section level2"> |
| 436 | +<h2>Revert</h2> |
| 437 | +<ol start="11" style="list-style-type: decimal"> |
| 438 | +<li>Checkout <em>master</em></li> |
| 439 | +<li>Create New text file, <code>colors.md</code> and list three of your favorite colors</li> |
| 440 | +<li>Commit and Push</li> |
| 441 | +<li>Add a fourth color to <code>colors.md</code> ; Commit and Push</li> |
| 442 | +<li>Observe the visual representations of the version history</li> |
| 443 | +<li>Now <em>revert</em> the last change because you changed your mind and you don’t have four favorite colors. In the terminal window type…</li> |
| 444 | +</ol> |
| 445 | +<div class="sourceCode"><pre class="sourceCode bash"><code class="sourceCode bash"><span class="fu">git</span> revert HEAD</code></pre></div> |
| 446 | +<ul> |
| 447 | +<li><code>:wq</code></li> |
| 448 | +</ul> |
| 449 | +<ol start="17" style="list-style-type: decimal"> |
| 450 | +<li>Commit and Push.</li> |
| 451 | +<li>Observe the visual representations of the version history</li> |
| 452 | +</ol> |
| 453 | +</div> |
341 | 454 |
|
342 | 455 | |
343 | 456 |
|
|
0 commit comments