Slide 1

Slide 1 text

git Brandon Mathis brandonmathis.me github.com/keysetts Friday, March 9, 12

Slide 2

Slide 2 text

Being clever isn’t helpful Friday, March 9, 12

Slide 3

Slide 3 text

Understanding your tools Friday, March 9, 12

Slide 4

Slide 4 text

Friday, March 9, 12

Slide 5

Slide 5 text

Friday, March 9, 12

Slide 6

Slide 6 text

git basic http://www.ndpsoftware.com/git- cheatsheet.html Friday, March 9, 12

Slide 7

Slide 7 text

git basic Friday, March 9, 12

Slide 8

Slide 8 text

5 parts to a git repo stash workspace index local repository (repo) upstream repo Friday, March 9, 12

Slide 9

Slide 9 text

5 parts to a git repo stash workspace index !!!local repository (repo)!!! upstream repo Friday, March 9, 12

Slide 10

Slide 10 text

workspace currently ‘work in progress’ changes code here does not technically exist Friday, March 9, 12

Slide 11

Slide 11 text

index (the tarmac) Friday, March 9, 12

Slide 12

Slide 12 text

index (the tarmac) Friday, March 9, 12

Slide 13

Slide 13 text

index (the tarmac) snapshot of current working tree staged changes live here, Friday, March 9, 12

Slide 14

Slide 14 text

local repo (0-20,000 ft) Friday, March 9, 12

Slide 15

Slide 15 text

local repo (0-20,000 ft) Friday, March 9, 12

Slide 16

Slide 16 text

local repo (0-20,000 ft) commits live here not set in stone! Friday, March 9, 12

Slide 17

Slide 17 text

upstream repo (32,000 feet) aka: origin Friday, March 9, 12

Slide 18

Slide 18 text

upstream repo (32,000 feet) Friday, March 9, 12

Slide 19

Slide 19 text

upstream repo (32,000 feet) where commits live and are shared Friday, March 9, 12

Slide 20

Slide 20 text

upstream repo (32,000 feet) default branches: -shared_feature_x -shared_feature_y -release_y Friday, March 9, 12

Slide 21

Slide 21 text

stash Friday, March 9, 12

Slide 22

Slide 22 text

stash Friday, March 9, 12

Slide 23

Slide 23 text

stash lots of development happening? stash your changes work on something new Friday, March 9, 12

Slide 24

Slide 24 text

stash Friday, March 9, 12

Slide 25

Slide 25 text

stash Friday, March 9, 12

Slide 26

Slide 26 text

stash Friday, March 9, 12

Slide 27

Slide 27 text

stash Friday, March 9, 12

Slide 28

Slide 28 text

stash Friday, March 9, 12

Slide 29

Slide 29 text

five layers of git Friday, March 9, 12

Slide 30

Slide 30 text

merge commits Friday, March 9, 12

Slide 31

Slide 31 text

the good Friday, March 9, 12

Slide 32

Slide 32 text

the bad Friday, March 9, 12

Slide 33

Slide 33 text

the ugly Friday, March 9, 12

Slide 34

Slide 34 text

merge commits how do I avoid them? :’( Friday, March 9, 12

Slide 35

Slide 35 text

live code time! Friday, March 9, 12

Slide 36

Slide 36 text

rebasing Friday, March 9, 12

Slide 37

Slide 37 text

rebasing Friday, March 9, 12

Slide 38

Slide 38 text

rebasing origin/head has diverged Friday, March 9, 12

Slide 39

Slide 39 text

rebasing git pull Friday, March 9, 12

Slide 40

Slide 40 text

rebasing git pull Friday, March 9, 12

Slide 41

Slide 41 text

the bad Friday, March 9, 12

Slide 42

Slide 42 text

rebasing Friday, March 9, 12

Slide 43

Slide 43 text

rebasing git rebase Friday, March 9, 12

Slide 44

Slide 44 text

rebasing git rebase Friday, March 9, 12

Slide 45

Slide 45 text

rebasing git rebase Friday, March 9, 12

Slide 46

Slide 46 text

easy enough! but how does hit stuff work?! Friday, March 9, 12

Slide 47

Slide 47 text

plumbing and porcelain plumbing hash-object read-tree write-tree update-ref ... porcelain add commit checkout branch remote stash push pull pop vs Friday, March 9, 12

Slide 48

Slide 48 text

basic structure of git dir Friday, March 9, 12

Slide 49

Slide 49 text

git is a database to be more specific: git is a key-value data store (content in, key out) What do I mean by that?! Friday, March 9, 12

Slide 50

Slide 50 text

git is a database store anything into git and get a key-value returned Friday, March 9, 12

Slide 51

Slide 51 text

live code time? Friday, March 9, 12

Slide 52

Slide 52 text

git is a database store anything into git and get a key-value returned Friday, March 9, 12

Slide 53

Slide 53 text

Create From existing data cd ~/my_project_dir git init git add . From existing repo git clone ~/existing/repo ~/new/repo git clone [email protected]:dir/project.git default protocol is ssh Browse Files changed in working directory git status Changes to tracked files git diff Changes between ID1 and ID2 git diff History of changes git log Who changed what and when in a file git blame A commit identified by ID git show A specific file from a specific ID git diff : Search for patterns git grep [path] Change Using your favorite editor / IDE Revert Return to the last committed state git checkout -f | git reset --hard you cannot undo a hard reset Revert the last commit git revert HEAD Creates a new commit Revert specific commit git revert $id Creates a new commit Fix the last commit git commit -a --amend after editing the broken files Checkout the ID version of a file git checkout Update Fetch latest changes from origin git fetch this does not merge them Pull latest changes from origin git pull does a fetch followed by a merge Apply a patch that someone sent you git am -3 patch.mbox In case of conflict, resolve the conflict and git am --resolve Commit Commit all local changes git commit -a Branch List all branches git branch Switch to the BRANCH branch git checkout Merge branch B1 into branch B2 git checkout git merge Create branch based on HEAD git branch Create branch based on another git branch Delete a branch git branch -d Publish Prepare a patch for other developers git format-patch origin Push changes to origin git push [origin] [branch] Make a version or milestone git tag Cheat Sheet This work is licensed under a Creative Commons Attribution-Share Alike 3.0 Unported License Useful tips Get help git help [command] Create empty branch git symbolic-ref HEAD refs/heads/newbranch rm .git/index git clean -fdx git add your files git commit -m 'Initial commit' Graphical log git log --graph git log --graph --pretty=oneline -- abbrev-commit Push branch to remote git push Delete remote branch and locally git push : git branch -d Resolve merge conflicts View merge conflicts git diff View merge conflicts against base file git diff --base View merge conflicts against other changes git diff --theirs View merge conflicts against your changes git diff --ours After resolving conflicts, merge with git add git rebase --continue Configuration git config [--global] global is stored in ~/.gitconfig user user.name $name user.email $email color color.ui auto github github.user $user github.token $token optimisation pack.threads 0 diff.renamelimit 0 do not use on low memory p windows core.autocrlf true http://github.com/AlexZeitler/gitcheatsheet Friday, March 9, 12

Slide 54

Slide 54 text

stashing: http://progit.org/book/ch6-3.html pro-git: http://progit.org/ git-book: http://progit.org/ebook/progit.pdf git visualized: http://www.ndpsoftware.com/ git-cheatsheet.html Friday, March 9, 12

Slide 55

Slide 55 text

Bob Anderson (1922-2012) Performed Darth Vader’s lightsaber duels (V, VI) Choreographed: Highlander The Princess Bride The three Musketeers Zorro LotR movies (The Hobbit) Friday, March 9, 12