├── .gitignore ├── advanced └── advanced.md ├── branch ├── 3way.png ├── backrefs.png ├── branch-master.png ├── branch.md ├── checkout-uppercase.png ├── delete-uppercase.png ├── diff-r1-r2.png ├── diverged.png ├── double-diverge.png ├── follow1.png ├── follow2.png ├── follow3.png ├── fork.png ├── gc-master.png ├── head-greeting.png ├── head-master.png ├── merge-uppercase.png ├── recursive.png ├── reset.png ├── split-deltas.png ├── uppercase.png └── wd-master.png ├── collab ├── collab.md ├── compare.png ├── diagrams.png ├── fetch.png ├── fix-remote.png ├── fix.png ├── github-repo.png ├── merge-upstream.png ├── sharing.png └── upstream.png ├── conclusion ├── conclusion.md └── progit.jpg ├── create ├── add.png ├── commit-c0.png ├── commit-c1.png ├── create.md ├── diff-cached.png ├── diff.png ├── dirty-c0.png ├── dirty-c0i.png ├── history1.png ├── history2.png ├── history2a.png ├── index.png └── wd.png ├── diagrams.graffle ├── install └── install.md ├── showoff.json ├── timer.js ├── title ├── title.md └── warning.png ├── tom.css └── tom.js /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /advanced/advanced.md: -------------------------------------------------------------------------------- 1 | !SLIDE 2 | 3 | # Fixing mistakes 4 | 5 | 6 | 7 | !SLIDE gitcmd 8 | 9 | # git commit --amend 10 | 11 | ## Modify the content of the **last commit** 12 | 13 |
14 |            $ vim README
15 |            $ git add -p
16 |            $ git commit --amend
17 | 
18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /branch/3way.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/3way.png -------------------------------------------------------------------------------- /branch/backrefs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/backrefs.png -------------------------------------------------------------------------------- /branch/branch-master.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/branch-master.png -------------------------------------------------------------------------------- /branch/branch.md: -------------------------------------------------------------------------------- 1 | !SLIDE reverse 2 | 3 | # Branching and Merging 4 | 5 | 6 | 7 | !SLIDE gitcmd 8 | 9 | # git branch 10 | 11 | ## Show all local branches 12 | 13 | $ git branch 14 | 15 | 16 | 17 | !SLIDE 18 | 19 | # The default branch is named 20 | 21 | # *master* 22 | 23 | 24 | 25 | !SLIDE center 26 | 27 | ## Branches are just pointers to commits 28 | 29 | ![branch-master](branch-master.png) 30 | 31 | 32 | 33 | !SLIDE center 34 | 35 | ## It's easiest to think of the working 36 | ## directory as corresponding to a branch 37 | 38 | ![wd-master](wd-master.png) 39 | 40 | 41 | 42 | !SLIDE center 43 | 44 | ## As you commit, the branch moves with you 45 | 46 | ![follow1](follow1.png) 47 | 48 | 49 | 50 | !SLIDE center 51 | 52 | ## As you commit, the branch moves with you 53 | 54 | ![follow2](follow2.png) 55 | 56 | 57 | 58 | !SLIDE center 59 | 60 | ## As you commit, the branch moves with you 61 | 62 | ![follow3](follow3.png) 63 | 64 | 65 | 66 | !SLIDE gitcmd 67 | 68 | # git branch 69 | 70 | ## Create a new branch pointing at 71 | ## the current commit 72 | 73 | $ git branch uppercase 74 | 75 | 76 | 77 | !SLIDE center 78 | 79 | ## A new branch has been created 80 | ## but the working dir has not changed 81 | 82 | ![uppercase](uppercase.png) 83 | 84 | 85 | 86 | !SLIDE gitcmd 87 | 88 | # git checkout 89 | 90 | ## Switch working dir to the given branch 91 | 92 | $ git checkout uppercase 93 | 94 | 95 | 96 | !SLIDE center 97 | 98 | ## Working dir now corresponds to *uppercase* 99 | 100 | ![checkout-uppercase](checkout-uppercase.png) 101 | 102 | 103 | 104 | !SLIDE 105 | 106 | ## Convert the string to uppercase 107 | ## on this branch and commit the change 108 | 109 | $ vim hello.sh 110 | $ git add -p 111 | $ git commit -m 'convert string to uppercase' 112 | 113 | 114 | 115 | !SLIDE center 116 | 117 | ## Branches have now diverged! 118 | 119 | ![diverged](diverged.png) 120 | 121 | 122 | 123 | !SLIDE gitcmd 124 | 125 | # git branch -v 126 | 127 | ## Show branches and the commits they point to 128 | 129 | $ git branch -v 130 | 131 | 132 | 133 | !SLIDE 134 | 135 | ## Switch back to the *master* branch. 136 | ## Notice that working dir has been changed. 137 | 138 |
139 | $ cat hello.sh        # uppercase version
140 | $ git checkout master
141 | $ cat hello.sh        # master version
142 | 
143 | 144 | 145 | 146 | !SLIDE center 147 | 148 | ## Working directory is now consistent 149 | ## with the *master* branch 150 | 151 | ![gc-master](gc-master.png) 152 | 153 | 154 | 155 | !SLIDE gitcmd 156 | 157 | # git diff R1 R2 158 | 159 | ## Diff between two arbitrary commits 160 | 161 | $ git diff master uppercase 162 | 163 | 164 | 165 | !SLIDE center 166 | 167 | ## Show the work done between branches 168 | 169 | ![diff-r1-r2](diff-r1-r2.png) 170 | 171 | 172 | 173 | !SLIDE gitcmd 174 | 175 | # git merge 176 | 177 | ## Merge the given commit into the current branch 178 | 179 | $ git merge uppercase 180 | 181 | 182 | 183 | !SLIDE center 184 | 185 | ## Both branches now point at the same commit 186 | 187 | ![merge-uppercase](merge-uppercase.png) 188 | 189 | 190 | 191 | 192 | !SLIDE 193 | 194 | ## This kind of merge is known as a 195 | ## **fast-forward merge** because the 196 | ## merged branch was a direct descendent 197 | 198 | 199 | 200 | !SLIDE gitcmd 201 | 202 | # git branch -d 203 | 204 | ## Delete the given branch 205 | 206 | $ git branch -d uppercase 207 | 208 | 209 | 210 | !SLIDE center 211 | 212 | ## Only the pointer has been deleted 213 | 214 | ![delete-uppercase](delete-uppercase.png) 215 | 216 | 217 | 218 | !SLIDE center 219 | 220 | ## What if both branches have commits? 221 | 222 | ![fork](fork.png) 223 | 224 | 225 | 226 | !SLIDE gitcmd 227 | 228 | # git checkout -b 229 | 230 | ## Create a new branch and switch to it 231 | 232 | $ git checkout -b greeting 233 | 234 | 235 | 236 | !SLIDE 237 | 238 | ## Modify the greetings; commit; 239 | ## and switch back to *master* 240 | 241 | $ vim hello.sh 242 | $ vim goodbye.sh 243 | $ git add -p 244 | $ git commit -m 'new greetings' 245 | $ git checkout master 246 | 247 | 248 | 249 | !SLIDE 250 | 251 | ## Create a new file on *master* 252 | ## and attempt to add it 253 | 254 |
255 |   $ vim README
256 |   $ git add -p       # nothing to review!
257 |   $ git status       # find out why
258 | 
259 | 260 | 261 | 262 | !SLIDE 263 | 264 | # File tracking 265 | 266 | ## Git remembers what files have been added. 267 | ## New files must be explicitly added. 268 | 269 | 270 | 271 | !SLIDE 272 | 273 | ## Add the contents of the new file 274 | 275 |
276 |     $ git add .   # add everything!
277 |     $ git status  # see that it worked
278 | 
279 | 280 | 281 | 282 | !SLIDE 283 | 284 | ## Oops, we forgot something... 285 | 286 |
287 |     $ vim README
288 |     $ git status        # make sure
289 | 
290 | 291 | 292 | 293 | !SLIDE center 294 | 295 | ## Two deltas have been introduced 296 | 297 | ![split-deltas](split-deltas.png) 298 | 299 | 300 | 301 | !SLIDE 302 | 303 | ## Inspect the deltas, and continue 304 | 305 |
306 |      $ git diff --staged # old change
307 |      $ git diff          # new change
308 |      $ git add -p        # add again
309 |      $ git commit -m "add a readme"
310 | 
311 | 312 | 313 | 314 | !SLIDE center 315 | 316 | ## Recap of forked lineage 317 | 318 | ![double-diverge](double-diverge.png) 319 | 320 | 321 | 322 | !SLIDE 323 | 324 | ## Merge *greeting* into *master* 325 | 326 | $ git merge greeting 327 | 328 | 329 | 330 | !SLIDE center 331 | 332 | ## A new merge commit (C5) is created 333 | 334 | ![recursive](recursive.png) 335 | 336 | 337 | 338 | !SLIDE 339 | 340 | ## This kind of merge is known as 341 | ## a **recursive merge** and 342 | ## uses a 3-way merge strategy 343 | 344 | 345 | 346 | !SLIDE center 347 | 348 | ## Three way (recursive) merge strategy 349 | 350 | ![3way](3way.png) 351 | 352 | 353 | 354 | !SLIDE gitcmd 355 | 356 | # git log --graph 357 | 358 | ## Show the commit log with graph structure 359 | 360 |
361 |              $ git log --graph
362 | 
363 | 364 | 365 | 366 | !SLIDE 367 | 368 | # The power of Undo 369 | 370 | 371 | 372 | !SLIDE 373 | 374 | # First, a word about references 375 | 376 | ## A reference is a way to refer to a commit 377 | 378 | 379 | 380 | !SLIDE bullets 381 | 382 | # Examples: 383 | 384 | * 5c673e53912d86eb771ee0ab0c678ecffa4b939c 385 | * 5c673e5 386 | * master 387 | * HEAD 388 | * HEAD^^ 389 | 390 | 391 | 392 | !SLIDE 393 | 394 | ## *HEAD* is a dynamic reference that 395 | ## follows your current checkout 396 | 397 | ![head-master](head-master.png) 398 | 399 | 400 | 401 | !SLIDE 402 | 403 | ## *HEAD* is a dynamic reference that 404 | ## follows your current checkout 405 | 406 | ![head-greeting](head-greeting.png) 407 | 408 | 409 | 410 | !SLIDE 411 | 412 | ## *HEAD* is a dynamic reference that 413 | ## follows your current checkout 414 | 415 | ![head-master](head-master.png) 416 | 417 | 418 | 419 | !SLIDE center 420 | 421 | ## Ancestry reference modifiers 422 | 423 | ![backrefs](backrefs.png) 424 | 425 | 426 | 427 | 428 | !SLIDE gitcmd 429 | 430 | # git reset --hard 431 | 432 | ## Reset a branch and working dir 433 | 434 | $ git reset --hard head^ 435 | 436 | 437 | 438 | !SLIDE center 439 | 440 | ## *master* is now pointing to C4. 441 | ## C5 still exists, but is **dangling**. 442 | 443 | ![reset](reset.png) 444 | 445 | 446 | 447 | !SLIDE gitcmd 448 | 449 | # git reflog 450 | 451 | ## Show previous values of *HEAD* 452 | 453 | $ git reflog 454 | 455 | 456 | 457 | !SLIDE 458 | 459 | # What about merge conflicts? 460 | 461 | 462 | 463 | !SLIDE 464 | 465 | ## Modify a line that was also changed 466 | ## in the *greeting* branch 467 | 468 | $ vim hello.sh 469 | $ git add -p 470 | 471 | 472 | 473 | !SLIDE gitcmd 474 | 475 | # git commit --amend 476 | 477 | ## Modify the content of the **last commit** 478 | 479 |
480 |            $ git commit --amend
481 | 
482 | 483 | 484 | 485 | !SLIDE 486 | 487 | ## Attempt to merge *greeting* 488 | 489 | $ git merge greeting 490 | 491 | 492 | 493 | !SLIDE 494 | 495 | ## Cleanly merged files are staged. 496 | ## Conflicts are left in working dir. 497 | 498 |
499 |        $ git diff --staged  # clean
500 |        $ git diff           # dirty
501 |        $ git status         # summary
502 | 
503 | 504 | 505 | 506 | !SLIDE 507 | 508 | ## Clean up the mess; use **git add** to mark 509 | ## a conflicted file as properly merged. 510 | ## Commit to seal the deal. 511 | 512 | $ git add hello.sh 513 | $ git commit -------------------------------------------------------------------------------- /branch/checkout-uppercase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/checkout-uppercase.png -------------------------------------------------------------------------------- /branch/delete-uppercase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/delete-uppercase.png -------------------------------------------------------------------------------- /branch/diff-r1-r2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/diff-r1-r2.png -------------------------------------------------------------------------------- /branch/diverged.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/diverged.png -------------------------------------------------------------------------------- /branch/double-diverge.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/double-diverge.png -------------------------------------------------------------------------------- /branch/follow1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/follow1.png -------------------------------------------------------------------------------- /branch/follow2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/follow2.png -------------------------------------------------------------------------------- /branch/follow3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/follow3.png -------------------------------------------------------------------------------- /branch/fork.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/fork.png -------------------------------------------------------------------------------- /branch/gc-master.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/gc-master.png -------------------------------------------------------------------------------- /branch/head-greeting.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/head-greeting.png -------------------------------------------------------------------------------- /branch/head-master.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/head-master.png -------------------------------------------------------------------------------- /branch/merge-uppercase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/merge-uppercase.png -------------------------------------------------------------------------------- /branch/recursive.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/recursive.png -------------------------------------------------------------------------------- /branch/reset.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/reset.png -------------------------------------------------------------------------------- /branch/split-deltas.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/split-deltas.png -------------------------------------------------------------------------------- /branch/uppercase.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/uppercase.png -------------------------------------------------------------------------------- /branch/wd-master.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/branch/wd-master.png -------------------------------------------------------------------------------- /collab/collab.md: -------------------------------------------------------------------------------- 1 | !SLIDE reverse 2 | 3 | # Collaboration 4 | 5 | 6 | 7 | !SLIDE 8 | 9 | ## Back to your repos directory 10 | 11 | $ cd .. 12 | 13 | 14 | 15 | !SLIDE gitcmd 16 | 17 | # git clone 18 | 19 | ## Clone a repository 20 | 21 | $ git clone hello helloclone 22 | $ cd helloclone 23 | 24 | 25 | 26 | !SLIDE center 27 | 28 | ## You can also clone from remote repositories 29 | 30 | ![github-repo](github-repo.png) 31 | 32 | 33 | 34 | !SLIDE gitcmd 35 | 36 | # git remote 37 | 38 | ## Display a list of remotes 39 | 40 | $ git remote -v 41 | 42 | 43 | 44 | !SLIDE gitcmd 45 | 46 | # git branch -a 47 | 48 | ## Show all branches (local and remote) 49 | 50 | $ git branch -a 51 | 52 | 53 | 54 | !SLIDE 55 | 56 | ## Assume that upstream makes a commit 57 | ## on the *master* branch 58 | 59 | 60 | 61 | !SLIDE center 62 | 63 | ## Current state of **upstream** 64 | 65 | ![upstream](upstream.png) 66 | 67 | 68 | 69 | !SLIDE gitcmd 70 | 71 | # git fetch 72 | 73 | ## Fetch commits from the given remote 74 | 75 | $ git fetch origin 76 | 77 | 78 | 79 | !SLIDE center 80 | 81 | ## Remote commits have been downloaded, 82 | ## but have not affected your local branches 83 | 84 | ![fetch](fetch.png) 85 | 86 | 87 | 88 | !SLIDE 89 | 90 | ## View the changes in the upstream 91 | ## *origin/master* branch 92 | 93 | $ git diff head origin/master 94 | 95 | 96 | 97 | !SLIDE center 98 | 99 | ## Comparing unmerged upstream commits 100 | 101 | ![compare](compare.png) 102 | 103 | 104 | 105 | !SLIDE 106 | 107 | ## Merge the upstream *origin/master* branch 108 | ## into your local *master* branch 109 | 110 | $ git merge origin/master 111 | 112 | 113 | 114 | !SLIDE center 115 | 116 | ## The upstream commits have been merged 117 | 118 | ![merge-upstream](merge-upstream.png) 119 | 120 | 121 | 122 | !SLIDE 123 | 124 | ## What if you want to share **your** changes? 125 | 126 | 127 | 128 | !SLIDE center 129 | 130 | ## Assume a new branch *fix* with a commit 131 | 132 | ![fix](fix.png) 133 | 134 | 135 | 136 | !SLIDE gitcmd 137 | 138 | # git push 139 | 140 | ## Push some commits to a remote 141 | 142 | $ git push origin fix 143 | 144 | 145 | 146 | !SLIDE center 147 | 148 | ## Remote now contains the *fix* branch! 149 | 150 | ![fix-remote](fix-remote.png) 151 | 152 | 153 | 154 | !SLIDE 155 | 156 | ## Now others that have access to the remote 157 | ## can fetch and work on the *fix* branch 158 | 159 | 160 | 161 | !SLIDE center 162 | 163 | ## Collaboration in Git is all about moving 164 | ## commits around between repositories 165 | 166 | ![sharing](sharing.png) -------------------------------------------------------------------------------- /collab/compare.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/collab/compare.png -------------------------------------------------------------------------------- /collab/diagrams.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/collab/diagrams.png -------------------------------------------------------------------------------- /collab/fetch.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/collab/fetch.png -------------------------------------------------------------------------------- /collab/fix-remote.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/collab/fix-remote.png -------------------------------------------------------------------------------- /collab/fix.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/collab/fix.png -------------------------------------------------------------------------------- /collab/github-repo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/collab/github-repo.png -------------------------------------------------------------------------------- /collab/merge-upstream.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/collab/merge-upstream.png -------------------------------------------------------------------------------- /collab/sharing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/collab/sharing.png -------------------------------------------------------------------------------- /collab/upstream.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/collab/upstream.png -------------------------------------------------------------------------------- /conclusion/conclusion.md: -------------------------------------------------------------------------------- 1 | !SLIDE center 2 | 3 | # Where do I go from here? 4 | 5 | 6 | 7 | !SLIDE center 8 | 9 | # Pro Git by Scott Chacon 10 | 11 | ## http://progit.org 12 | 13 | ![progit](progit.jpg) 14 | 15 | 16 | 17 | !SLIDE 18 | 19 | # Thanks! -------------------------------------------------------------------------------- /conclusion/progit.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/conclusion/progit.jpg -------------------------------------------------------------------------------- /create/add.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/create/add.png -------------------------------------------------------------------------------- /create/commit-c0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/create/commit-c0.png -------------------------------------------------------------------------------- /create/commit-c1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/create/commit-c1.png -------------------------------------------------------------------------------- /create/create.md: -------------------------------------------------------------------------------- 1 | !SLIDE reverse 2 | 3 | # Creating and Committing 4 | 5 | 6 | 7 | !SLIDE 8 | 9 | ## Make a directory for your new project 10 | 11 | $ cd path/to/repos 12 | $ mkdir hello 13 | $ cd hello 14 | 15 | 16 | 17 | !SLIDE center 18 | 19 | ## Working directory 20 | 21 | ![wd](wd.png) 22 | 23 | 24 | 25 | !SLIDE gitcmd 26 | 27 | # git init 28 | 29 |
 30 |       $ ls -al    # dir is empty
 31 |       $ git init  # initialize git repo
 32 |       $ ls -al    # new .git dir
 33 | 
34 | 35 | 36 | 37 | !SLIDE center 38 | 39 | ## Behold the index! 40 | 41 | ![index](index.png) 42 | 43 | 44 | 45 | !SLIDE 46 | 47 | ## Write some code 48 | 49 | $ vim hello.sh 50 | $ vim goodbye.sh 51 | 52 | 53 | 54 | !SLIDE gitcmd 55 | 56 | # git add 57 | 58 |
 59 | $ git add hello.sh   # add content to index
 60 | $ git add goodbye.sh # add content to index
 61 | 
62 | 63 | 64 | 65 | !SLIDE center 66 | 67 | ## Index now contains working dir content 68 | 69 | ![add](add.png) 70 | 71 | 72 | 73 | !SLIDE gitcmd 74 | 75 | # git status 76 | 77 | ## Show the status of index and working dir 78 | 79 |
 80 |                $ git status
 81 | 
82 | 83 | 84 | 85 | !SLIDE gitcmd 86 | 87 | # git commit 88 | 89 |
 90 |       $ git commit  # make a commit
 91 | 
92 | 93 | 94 | 95 | !SLIDE center 96 | 97 | ## A commit is a snapshot taken from the index 98 | 99 |

NOT THE WORKING DIRECTORY

100 | 101 | ![commit-c0](commit-c0.png) 102 | 103 | 104 | 105 | !SLIDE gitcmd 106 | 107 | # git log 108 | 109 | ## Print a log of commits 110 | 111 |
112 |                  $ git log
113 | 
114 | 115 | 116 | 117 | !SLIDE center 118 | 119 | # Recap 120 | 121 | ## The current state of the repo 122 | 123 | ![history1](history1.png) 124 | 125 | 126 | 127 | !SLIDE 128 | 129 | ## Make some ambitious changes 130 | 131 |
132 |      $ vim hello.sh  # modify the file
133 | 
134 | 135 | 136 | 137 | !SLIDE center 138 | 139 | ## Working dir now contains D0: a delta from C0 140 | 141 | ![dirty-c0](dirty-c0.png) 142 | 143 | 144 | 145 | !SLIDE 146 | 147 | ## Review the changed files 148 | 149 |
150 |                $ git status
151 | 
152 | 153 | 154 | 155 | 156 | !SLIDE gitcmd 157 | 158 | # git diff 159 | 160 | ## Show diff between index and working dir 161 | 162 |
163 |                 $ git diff
164 | 
165 | 166 | 167 | 168 | !SLIDE center 169 | 170 | ## D0 = Diff(Index, WorkingDir) 171 | 172 | ![diff](diff.png) 173 | 174 | 175 | 176 | !SLIDE gitcmd 177 | 178 | # git add -p 179 | 180 | ## Interactively add changed hunks 181 | 182 |
183 |                $ git add -p
184 | 
185 | 186 | 187 | 188 | !SLIDE center 189 | 190 | ## D0 is now in working dir AND index 191 | 192 | ![dirty-c0i](dirty-c0i.png) 193 | 194 | 195 | 196 | !SLIDE 197 | 198 | # **git diff** now shows nothing! 199 | 200 | ## Where did it go? 201 | 202 | 203 | 204 | !SLIDE gitcmd 205 | 206 | # git diff --staged 207 | 208 | ## Show diff between commit and index 209 | 210 |
211 |             $ git diff --staged
212 | 
213 | 214 | 215 | 216 | !SLIDE center 217 | 218 | ## D0 = Diff(Commit, Index) 219 | 220 | ![diff-cached](diff-cached.png) 221 | 222 | 223 | 224 | !SLIDE gitcmd 225 | 226 | # git commit -m 227 | 228 | ## Create a commit with the given commit message 229 | 230 | $ git commit -m "more ambition!" 231 | 232 | 233 | 234 | !SLIDE center 235 | 236 | ## Commit is rolled from index 237 | 238 | ![commit-c1](commit-c1.png) 239 | 240 | 241 | 242 | !SLIDE 243 | 244 | # Remember: 245 | 246 |
    247 |
  1. Make changes to working dir
  2. 248 |
  3. Stage those changes to the index
  4. 249 |
  5. Commit the current state of the index
  6. 250 |
251 | 252 | 253 | !SLIDE center 254 | 255 | # Recap 256 | 257 | ## Two commits, C0 and C1 258 | 259 | ![history2](history2.png) 260 | 261 | 262 | 263 | !SLIDE center 264 | 265 | ## Every commit has zero or 266 | ## more parent commits 267 | 268 | ![history2a](history2a.png) -------------------------------------------------------------------------------- /create/diff-cached.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/create/diff-cached.png -------------------------------------------------------------------------------- /create/diff.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/create/diff.png -------------------------------------------------------------------------------- /create/dirty-c0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/create/dirty-c0.png -------------------------------------------------------------------------------- /create/dirty-c0i.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/create/dirty-c0i.png -------------------------------------------------------------------------------- /create/history1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/create/history1.png -------------------------------------------------------------------------------- /create/history2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/create/history2.png -------------------------------------------------------------------------------- /create/history2a.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/create/history2a.png -------------------------------------------------------------------------------- /create/index.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/create/index.png -------------------------------------------------------------------------------- /create/wd.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/create/wd.png -------------------------------------------------------------------------------- /install/install.md: -------------------------------------------------------------------------------- 1 | !SLIDE reverse 2 | 3 | # Installing Git 4 | 5 | !SLIDE bullets 6 | 7 | # Mac 8 | 9 | * Git OSX Installer 10 | * Homebrew 11 | * MacPorts 12 | * Manually 13 | 14 | !SLIDE bullets 15 | 16 | # Linux 17 | 18 | * Apt 19 | * Ports 20 | * Yum 21 | * Manually 22 | 23 | !SLIDE bullets 24 | 25 | # Windows 26 | 27 | * msysgit 28 | 29 | !SLIDE bullets 30 | 31 | # help.github.com 32 | 33 | !SLIDE commandline 34 | 35 | # Initial Configuration 36 | 37 | ## http://gist.github.com/340818 38 | 39 | $ git config --global user.name "Tom Preston-Werner" 40 | $ git config --global user.email "tom@mojombo.com" 41 | 42 | $ git config --global color.ui true 43 | -------------------------------------------------------------------------------- /showoff.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"section":"title"}, 3 | {"section":"install"}, 4 | {"section":"create"}, 5 | {"section":"branch"}, 6 | {"section":"collab"}, 7 | {"section":"conclusion"} 8 | ] 9 | -------------------------------------------------------------------------------- /timer.js: -------------------------------------------------------------------------------- 1 | var timerSetUp = false; 2 | var timerRunning = false; 3 | var intervalRunning = false; 4 | var seconds = 0; 5 | var totalMinutes = 25; 6 | 7 | function setUpTimer() 8 | { 9 | if (timerSetUp) { return; } 10 | 11 | timerSetUp = true; 12 | 13 | $("#slideInfo").after('   '); 14 | 15 | $(document).keydown(function(event) { 16 | var key = event.keyCode; 17 | if (event.ctrlKey || event.altKey || event.metaKey) { return; } 18 | 19 | if (key == 89) // y for timer 20 | { 21 | toggleTimer(); 22 | } 23 | }); 24 | } 25 | 26 | function toggleTimer() 27 | { 28 | if (!timerRunning) { 29 | timerRunning = true 30 | $("#timerInfo").text(timerStatus(0)); 31 | seconds = 0 32 | if (!intervalRunning) { 33 | intervalRunning = true 34 | setInterval(function() { 35 | if (!timerRunning) { return; } 36 | seconds++; 37 | $("#timerInfo").text(timerStatus(seconds)); 38 | }, 1000); // fire every minute 39 | } 40 | } else { 41 | seconds = 0 42 | timerRunning = false 43 | $("#timerInfo").text('') 44 | } 45 | } 46 | 47 | function timerStatus(seconds) { 48 | var minutes = Math.round(seconds / 60); 49 | var left = (totalMinutes - minutes); 50 | var percent = Math.round((minutes / totalMinutes) * 100); 51 | var progress = getSlidePercent() - percent; 52 | setProgressIcon(progress); 53 | return ' - (' + minutes + '/' + left + ':' + percent + '%)'; 54 | } 55 | 56 | function setProgressIcon(progress) { 57 | if(progress > 10) { 58 | $('#progressIcon').attr('src', '/image/timer/flag_blue.png') 59 | } else if (progress > 0) { 60 | $('#progressIcon').attr('src', '/image/timer/flag_green.png') 61 | } else if (progress > -10) { 62 | $('#progressIcon').attr('src', '/image/timer/flag_yellow.png') 63 | } else { 64 | $('#progressIcon').attr('src', '/image/timer/flag_red.png') 65 | } 66 | } 67 | 68 | $(function(){ 69 | setUpTimer(); 70 | }); -------------------------------------------------------------------------------- /title/title.md: -------------------------------------------------------------------------------- 1 | !SLIDE 2 | # Mastering Git Basics 3 | 4 | ## by Tom Preston-Werner 5 | 6 | 7 | 8 | !SLIDE 9 | 10 | # @mojombo 11 | 12 | 13 | 14 | !SLIDE 15 | 16 | ## Before we start... 17 | 18 | 19 | 20 | !SLIDE center 21 | 22 | ![warning](warning.png) 23 | 24 | ## Forget everything you know 25 | ## about version control -------------------------------------------------------------------------------- /title/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mojombo/mastering-git-basics/f32325fb30f264abd0d204799f0771ec2641c9ee/title/warning.png -------------------------------------------------------------------------------- /tom.css: -------------------------------------------------------------------------------- 1 | div.reversed { 2 | background-color: black; 3 | color: white; 4 | } 5 | 6 | div.gitcmd h1 { 7 | color: red; 8 | } 9 | 10 | .comment { 11 | color: gray; 12 | } 13 | 14 | strong { 15 | color: red; 16 | font-weight: normal; 17 | } 18 | 19 | em { 20 | color: green; 21 | font-style: normal; 22 | } 23 | 24 | u { 25 | color: blue; 26 | } -------------------------------------------------------------------------------- /tom.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | setTimeout(function() { 3 | $("div.reverse").parent("div.slide").addClass("reversed") 4 | }, 2000) 5 | }) --------------------------------------------------------------------------------