git
TRANSCRIPT
![Page 1: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/1.jpg)
Git Some LerninHow To Git For Great Good
![Page 2: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/2.jpg)
Why Version Control?
• Because I Say So.
![Page 3: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/3.jpg)
Why Git?
• Because I Say So.
![Page 4: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/4.jpg)
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
![Page 5: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/5.jpg)
Porcelain
![Page 6: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/6.jpg)
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
![Page 7: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/7.jpg)
How To Branch
• git checkout -b improvement/unicorns
• git branch bug/voldemort && git checkout bug/voldemort
![Page 8: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/8.jpg)
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
![Page 9: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/9.jpg)
Commit Messages
• Start with bug number and short description <70 characters
• Longer description after one blank line
![Page 10: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/10.jpg)
Index == Staging
• STAGE EVERYTHING
• Save time later by staging only some logical changes now
![Page 11: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/11.jpg)
Demo
![Page 12: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/12.jpg)
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
![Page 13: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/13.jpg)
Remotes
[remote "origin"] url = [email protected]:ranman/fancy-project.git fetch = +refs/heads/*:refs/remotes/origin/*
![Page 14: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/14.jpg)
Everything is an object(content addressable storage)
![Page 15: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/15.jpg)
• 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
![Page 16: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/16.jpg)
![Page 17: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/17.jpg)
![Page 18: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/18.jpg)
![Page 19: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/19.jpg)
You're just moving some pointers around.
![Page 20: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/20.jpg)
Dat Network
![Page 21: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/21.jpg)
![Page 22: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/22.jpg)
![Page 23: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/23.jpg)
Fancy Random Things
![Page 24: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/24.jpg)
Find Lost Stuff
• git reflog
• git fsck [--lost-found]
• git log -G
• git branch --contains SHA-1
![Page 25: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/25.jpg)
Find Bugs
• git bisect
![Page 26: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/26.jpg)
tig
![Page 27: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/27.jpg)
git log branchA ^branchB
![Page 28: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/28.jpg)
git log branchA..branchB git log branchB..branchA git log branchA...branchB
![Page 29: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/29.jpg)
Undo
• git reset --soft HEAD^
• git reset --hard HEAD^
![Page 30: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/30.jpg)
Config
• git config --global help.autocorrect 1
• git config --global rerere.enabled 1
• git config --global color.ui 1
• git diff --word-diff
![Page 31: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/31.jpg)
![Page 32: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/32.jpg)
gitshots
![Page 33: Git](https://reader034.vdocument.in/reader034/viewer/2022051515/554f5931b4c905b9508b529a/html5/thumbnails/33.jpg)