Git

118
-1

Published on

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
118
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Git

  1. 1. Git Some Lernin How To Git For Great Good
  2. 2. Why Version Control? • Because I Say So.
  3. 3. Why Git? • Because I Say So.
  4. 4. Vocabulary • Repository -- Holds the history of all changes • Commit -- A point in time snapshot of your repo • Reference -- Something that makes it so you don't have to remember a 40 hexadecimal digit sha1 hash • Branch -- A pointer to the head of a group of commits • Remote -- A thing you push to and pull from • Pull Request -- How you get your code reviewed (unless you're on kernel) • Github -- Magic
  5. 5. Porcelain
  6. 6. 1. Fork a project 2. Clone your fork 3. Branch 4. Edit some files 5. Commit 6. Repeat 4 and 5 until feature/bug is complete 7. REBASE to create a history that I won't mind reading through 8. Pull any changes that have happened on non-forked master in the interim and rebase on top of those if you want a linear history otherwise do nothing for this step 9. Open pull request from your branch on your fork into the canonical repo's master branch 10. Profit
  7. 7. How To Branch • git checkout -b improvement/unicorns • git branch bug/voldemort && git checkout bug/voldemort
  8. 8. How To Commit • Edit Some Stuff • git add -p and git add (DO NOT GIT ADD * or .) • Review what is in staging with git diff --cached and git status • git commit
  9. 9. Commit Messages • Start with bug number and short description <70 characters • Longer description after one blank line
  10. 10. Index == Staging • STAGE EVERYTHING • Save time later by staging only some logical changes now
  11. 11. Demo
  12. 12. Refs • N^ goes up N parents (HEAD^, HEAD^100) • ~ selects merge parents (HEAD~, HEAD~2) • Mix and match (don't actually though) • HEAD is hard coded and always points to the current head of whatever branch you have checked out • Almost everything can be treated as a ref
  13. 13. Remotes [remote "origin"] url = git@github.com:ranman/fancy-project.git fetch = +refs/heads/*:refs/remotes/origin/*
  14. 14. Everything is an object (content addressable storage)
  15. 15. • Blob (zlib compressed bytes representing a file) • Tree (a tree where the leaf nodes are blobs) • Commit (a pointer to: a tree, n parent commits) • Tag (a pointer to a commit) • (IGNORE THIS) something something packfiles
  16. 16. You're just moving some pointers around.
  17. 17. Dat Network
  18. 18. Fancy Random Things
  19. 19. Find Lost Stuff • git reflog • git fsck [--lost-found] • git log -G • git branch --contains SHA-1
  20. 20. Find Bugs • git bisect
  21. 21. tig
  22. 22. git log branchA ^branchB
  23. 23. git log branchA..branchB git log branchB..branchA git log branchA...branchB
  24. 24. Undo • git reset --soft HEAD^ • git reset --hard HEAD^
  25. 25. Config • git config --global help.autocorrect 1 • git config --global rerere.enabled 1 • git config --global color.ui 1 • git diff --word-diff
  26. 26. gitshots
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×