Slide 1

Slide 1 text

Git Some Lernin How To Git For Great Good

Slide 2

Slide 2 text

Why Version Control? • Because I Say So.

Slide 3

Slide 3 text

Why Git? • Because I Say So.

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

Porcelain

Slide 6

Slide 6 text

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

Slide 7

Slide 7 text

How To Branch • git checkout -b improvement/unicorns • git branch bug/voldemort && git checkout bug/voldemort

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

Commit Messages • Start with bug number and short description <70 characters • Longer description after one blank line

Slide 10

Slide 10 text

Index == Staging • STAGE EVERYTHING • Save time later by staging only some logical changes now

Slide 11

Slide 11 text

Demo

Slide 12

Slide 12 text

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

Slide 13

Slide 13 text

Remotes [remote "origin"] url = [email protected]:ranman/fancy-project.git fetch = +refs/heads/*:refs/remotes/origin/*

Slide 14

Slide 14 text

Everything is an object (content addressable storage)

Slide 15

Slide 15 text

• 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

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

You're just moving some pointers around.

Slide 20

Slide 20 text

Dat Network

Slide 21

Slide 21 text

No content

Slide 22

Slide 22 text

No content

Slide 23

Slide 23 text

Fancy Random Things

Slide 24

Slide 24 text

Find Lost Stuff • git reflog • git fsck [--lost-found] • git log -G • git branch --contains SHA-1

Slide 25

Slide 25 text

Find Bugs • git bisect

Slide 26

Slide 26 text

tig

Slide 27

Slide 27 text

git log branchA ^branchB

Slide 28

Slide 28 text

git log branchA..branchB git log branchB..branchA git log branchA...branchB

Slide 29

Slide 29 text

Undo • git reset --soft HEAD^ • git reset --hard HEAD^

Slide 30

Slide 30 text

Config • git config --global help.autocorrect 1 • git config --global rerere.enabled 1 • git config --global color.ui 1 • git diff --word-diff

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

gitshots

Slide 33

Slide 33 text

No content