|
| 1 | +--- |
| 2 | +title: Git and GitHub |
| 3 | +type: slides |
| 4 | +order: 1 |
| 5 | +--- |
| 6 | + |
| 7 | +<!-- .slide: data-state="title" --> |
| 8 | + |
| 9 | +# Automated Version Control |
| 10 | + |
| 11 | +What is version control and why should I use it? |
| 12 | + |
| 13 | +Note: |
| 14 | +- Git all set up? |
| 15 | +- SSH working? |
| 16 | +- Otherwise: breakout room |
| 17 | + |
| 18 | +=== |
| 19 | + |
| 20 | +<!-- .slide: data-state="standard" --> |
| 21 | +<img style="height: 70vh;" src="https://swcarpentry.github.io/git-novice/fig/phd101212s.png"/> |
| 22 | + |
| 23 | +<span style="font-size: small;">“Piled Higher and Deeper” by Jorge Cham, http://www.phdcomics.com </span> |
| 24 | + |
| 25 | +=== |
| 26 | + |
| 27 | +<!-- .slide: data-state="standard" --> |
| 28 | +## Documents are... |
| 29 | +<div class="fragment"> |
| 30 | + a series of changes |
| 31 | + <img style="height: 30vh; margin: 0; padding: 0;" src="https://swcarpentry.github.io/git-novice/fig/play-changes.svg"/> |
| 32 | +</div> |
| 33 | + |
| 34 | +=== |
| 35 | + |
| 36 | +<!-- .slide: data-state="standard" --> |
| 37 | +## Collaboration |
| 38 | +<div style="float: left; width: 49%;"> |
| 39 | + independent changes |
| 40 | + <img style="height: 350px;" src="./media/versions.svg"/> |
| 41 | +</div> |
| 42 | +<div class="fragment" style="float: right; width: 49%;"> |
| 43 | + can be merged |
| 44 | + <img style="height: 350px;" src="./media/merge.svg"/> |
| 45 | +</div> |
| 46 | + |
| 47 | +=== |
| 48 | + |
| 49 | +<!-- .slide: data-state="standard" --> |
| 50 | +## Version Control: Key Points |
| 51 | + |
| 52 | +- Version control is track changes on steroids. |
| 53 | +- Version control is like an unlimited **undo**. |
| 54 | +- Version control also allows many people to work in parallel. |
| 55 | + |
| 56 | +=== |
| 57 | + |
| 58 | +<!-- .slide: data-state="standard" --> |
| 59 | +## The Holy Realms of Git |
| 60 | + |
| 61 | +<img src="https://swcarpentry.github.io/git-novice/fig/git-staging-area.svg"> |
| 62 | + |
| 63 | +<ul> |
| 64 | + <li><b>workspace</b> 📂</li> |
| 65 | + <ul> |
| 66 | + <li>Your filesystem</li> |
| 67 | + </ul> |
| 68 | + <li class="fragment"><b>index</b> 🕒 |
| 69 | + <ul> |
| 70 | + <li>Staging area</li> |
| 71 | + <li>Files wait patiently to be committed</li> |
| 72 | + </ul> |
| 73 | + </li> |
| 74 | + <li class="fragment"><b>local repository</b> 🗂️ |
| 75 | + <ul> |
| 76 | + <li>Contains branches, commits, history, etc.</li> |
| 77 | + </ul> |
| 78 | + </li> |
| 79 | +<ul> |
| 80 | + |
| 81 | +=== |
| 82 | + |
| 83 | +<!-- .slide: data-state="standard" --> |
| 84 | +## Crowded Staging Area / Index |
| 85 | + |
| 86 | +<img src="https://swcarpentry.github.io/git-novice/fig/git-committing.svg"> |
| 87 | + |
| 88 | +The Staging Area / Index can hold many files and folders. |
| 89 | + |
| 90 | +=== |
| 91 | + |
| 92 | +<!-- .slide: data-state="standard" --> |
| 93 | +## Quiz 1/2 |
| 94 | + |
| 95 | +<blockquote style="text-align: left;"> |
| 96 | +Which commit message should I choose? |
| 97 | +<ol> |
| 98 | + <li>“Changes”</li> |
| 99 | + <li>“Added line ‘This project started as a joke’ to myfile.txt”</li> |
| 100 | + <li>“Discuss origin of the project”</li> |
| 101 | +</ol> |
| 102 | +</code></pre> |
| 103 | +</blockquote> |
| 104 | +<blockquote class="fragment" style="text-align: right;"> |
| 105 | +Make it short, descriptive, and imperative <span style="font-style: normal;">🐺</span> |
| 106 | +</blockquote> |
| 107 | +<blockquote class="fragment" style="text-align: right;"> |
| 108 | +So yeah, the last one is good! <span style="font-style: normal;">🐺</span> |
| 109 | +</blockquote> |
| 110 | + |
| 111 | +=== |
| 112 | + |
| 113 | +<!-- .slide: data-state="standard" --> |
| 114 | +## Quiz 2/2 |
| 115 | + |
| 116 | +<blockquote style="text-align: left;"> |
| 117 | +Which command saves <b>myfile.txt</b> to my Git repo?<br> |
| 118 | +<ol> |
| 119 | + <li> |
| 120 | + <pre style="width: 100%; font-style: normal;" data-id="code-animation"><code data-trim class="bash"> |
| 121 | + $ git commit -m "my recent changes" |
| 122 | + </code></pre> |
| 123 | + </li> |
| 124 | + <li> |
| 125 | + <pre style="width: 100%; font-style: normal;" data-id="code-animation"><code data-trim class="bash"> |
| 126 | + $ git init myfile.txt |
| 127 | + $ git commit -m "my recent changes" |
| 128 | + </code></pre> |
| 129 | + </li> |
| 130 | + <li> |
| 131 | + <pre style="width: 100%; font-style: normal;" data-id="code-animation"><code data-trim class="bash"> |
| 132 | + $ git add myfile.txt |
| 133 | + $ git commit -m "my recent changes" |
| 134 | + </code></pre> |
| 135 | + </li> |
| 136 | + <li> |
| 137 | + <pre style="width: 100%; font-style: normal;" data-id="code-animation"><code data-trim class="bash"> |
| 138 | + $ git commit -m myfile.txt "my recent changes" |
| 139 | + </code></pre> |
| 140 | + </li> |
| 141 | +</ol> |
| 142 | +</code></pre> |
| 143 | +</blockquote> |
| 144 | +<blockquote class="fragment" style="text-align: right;"> |
| 145 | +3. adds your file to the index, and then commits it. That's the one. |
| 146 | +<span style="font-style: normal;">🐺</span> |
| 147 | +</blockquote> |
| 148 | + |
| 149 | + |
| 150 | +=== |
| 151 | + |
| 152 | +<!-- .slide: data-state="standard" --> |
| 153 | +## Tracking Changes: Key Points |
| 154 | + |
| 155 | +- Files can be stored in |
| 156 | + - **working directory**: the files you can see |
| 157 | + - **staging area / index**: files about to be committed |
| 158 | + - **local repository**: the permanent record |
| 159 | +- **git status** shows the status of a repository |
| 160 | +- **git add** puts files in the staging area |
| 161 | +- **git commit** saves the staged content as a new commit in the local repository |
| 162 | +- Write short, descriptive, and imperative commit messages |
0 commit comments