Thinking in Git
-
Upload
great-wide-open -
Category
Technology
-
view
87 -
download
1
Transcript of Thinking in Git
![Page 1: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/1.jpg)
http://www.craftychild.com/finger-painting.htmlhttp://pixabay.com/en/cherry-sweet-cherry-red-fruit-167341/
Thinking in Git
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
1 of 70 03/21/2016 03:06 PM
![Page 2: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/2.jpg)
Hi
Emily Dunham
edunham on irc.freenode.net
@qedunham
talks.edunham.net/gwo2016/git
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
2 of 70 03/21/2016 03:06 PM
![Page 3: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/3.jpg)
Agenda
How to look at softwaredevelopment
What's Git?
Essential Git concepts &commands
GitHub
Demo!
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
3 of 70 03/21/2016 03:06 PM
![Page 4: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/4.jpg)
Thinking about Software Development
Changing filesSome changes manual, other changes automatic
Changes for different reasonsAdd feature, fix bug, test idea
Sometimes have several reasons at once, wantchanges separate
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
4 of 70 03/21/2016 03:06 PM
![Page 5: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/5.jpg)
Why version control?
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
5 of 70 03/21/2016 03:06 PM
![Page 6: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/6.jpg)
How do you track changes?
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
6 of 70 03/21/2016 03:06 PM
![Page 7: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/7.jpg)
Goals of Distributed Version Control
Get the same file out that you put in
Work in parallel with others
Recombine individual work into oneproject
Track and quantify changes over time
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
7 of 70 03/21/2016 03:06 PM
![Page 8: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/8.jpg)
Using Git
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
8 of 70 03/21/2016 03:06 PM
![Page 9: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/9.jpg)
Setting Up
Tell Git who you are:
$ git config --global user.name "John Doe"$ git config --global user.email [email protected]
You'll need SSH keys laterssh-keygen -t rsa -b 2048, or
ssh-keygen -t ecdsa
Install Git (also tk and tcl if you want the GUI)
Set preferred editorexport GIT_EDITOR=vim in ~/.bashrc orequivalent
Pick a project to work on
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
9 of 70 03/21/2016 03:06 PM
![Page 10: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/10.jpg)
Imagine...You can time travel through the history of anyproject!
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
10 of 70 03/21/2016 03:06 PM
![Page 11: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/11.jpg)
What's a repository?
Database of snapshots of your code
Universe whose history you can travel through
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
11 of 70 03/21/2016 03:06 PM
![Page 12: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/12.jpg)
Getting a repo
$ git init # Make a brand new repo
$ git clone <git clone url> # Start with a copy of another
# [email protected]:organization/reponame.git# https://github.com/organization/reponame.git
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
12 of 70 03/21/2016 03:06 PM
![Page 13: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/13.jpg)
Looking at a repo
$ ls .git/
$ git showfatal: bad default revision 'HEAD'# To be expected with nothing in the repo
$ git showfatal: Not a git repository (or any of the parent directories): .git# not in a repo
$ git log
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
13 of 70 03/21/2016 03:06 PM
![Page 14: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/14.jpg)
Undo repository creation
Warning
This deletes your history. Only do it if you really want tostop having a Git repo here.
$ rm -rf .git
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
14 of 70 03/21/2016 03:06 PM
![Page 15: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/15.jpg)
Imagine...What if you had to publish every change as soon asyou made it?
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
15 of 70 03/21/2016 03:06 PM
![Page 16: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/16.jpg)
How Git sees your projectUnstaged | Staged | Committed
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
16 of 70 03/21/2016 03:06 PM
![Page 17: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/17.jpg)
Imagine...
You decide exactly where time travelers are allowedto land.
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
17 of 70 03/21/2016 03:06 PM
![Page 18: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/18.jpg)
What're staged changes?
Think "backstage", changes "waiting in the wings"
Files or parts of files can be added or removed
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
18 of 70 03/21/2016 03:06 PM
![Page 19: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/19.jpg)
Staging changes
$ echo "hello Great Wide Open" > foo$ git add foo
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
19 of 70 03/21/2016 03:06 PM
![Page 20: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/20.jpg)
Looking at staged changes
$ touch bar$ git statusOn branch master
Initial commit
Changes to be committed:(use "git rm --cached <file>..."
to unstage) new file: foo Untracked files:
(use "git add <file>..." to include in what will be committed) bar$ git commit --dry-run
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
20 of 70 03/21/2016 03:06 PM
![Page 21: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/21.jpg)
Undo?
Keeping uncommitted changes
$ git rm --cached foo
Go back to the latest committed version
$ git reset HEAD foo
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
21 of 70 03/21/2016 03:06 PM
![Page 22: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/22.jpg)
Imagine...
Time travelers get some signs and instructions whenthey arrive
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
22 of 70 03/21/2016 03:06 PM
![Page 23: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/23.jpg)
Thinking about snapshots
Changes to a file plus pointers tounchanged files
Each snapshot knows the state of alltracked files
More efficient than just copying
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
23 of 70 03/21/2016 03:06 PM
![Page 24: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/24.jpg)
What's a commit?snapshot of changes, author, date, committer (can differfrom author), parent commit
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
24 of 70 03/21/2016 03:06 PM
![Page 25: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/25.jpg)
Making a commit
$ git commit
$ man git-commit-a, --all-i, --interactive--reset-author--date=<date> (see DATE FORMATS in man page)--allow-empty--amend-o, --only-S, --gpg-sign
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
25 of 70 03/21/2016 03:06 PM
![Page 26: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/26.jpg)
Looking at commits
# details on latest or specified$ git show
# Summary of recent, or a range$ git log
$ man gitrevisions # ranges
What about commits per file?
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
26 of 70 03/21/2016 03:06 PM
![Page 27: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/27.jpg)
Commit display options
$ git show
$ git show --oneline
# see PRETTY FORMATS section of$ man git-show
# Check the GPG signature$ git show --show-signature
# Want a GUI?$ gitk
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
27 of 70 03/21/2016 03:06 PM
![Page 28: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/28.jpg)
Undo?
# just one file$ git checkout <commit> <filename>$ git add <filename>$ git commit -m "i put that file back how it was"
Or undo the whole commit
$ git revert <commit to revert to>
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
28 of 70 03/21/2016 03:06 PM
![Page 29: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/29.jpg)
Imagine...Time travelers get a list of especially interestinglocations to visit
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
29 of 70 03/21/2016 03:06 PM
![Page 30: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/30.jpg)
What's a tag?
Marker attached to aspecific commit
Typically used for version orrelease number
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
30 of 70 03/21/2016 03:06 PM
![Page 31: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/31.jpg)
Adding a Tag
$ man git-tag$ git tag -m <msg> <tagname>
Default is lightweight tag -- just a reference for SHA-1 oflatest commit
Pass -s or -u <key-id> to GPG-sign
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
31 of 70 03/21/2016 03:06 PM
![Page 32: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/32.jpg)
Looking at Tags
# List all available tags$ git tag
# List tags matching regex$ git tag -l 'regex'
# I want this version!$ git checkout <tag name>
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
32 of 70 03/21/2016 03:06 PM
![Page 33: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/33.jpg)
Undo?
$ git tag -d <tagname>
# And remove it from a remote repo$ git push origin :refs/tags/<tagname>
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
33 of 70 03/21/2016 03:06 PM
![Page 34: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/34.jpg)
Imagine...You can work on separate sets of changes that don'taffect each other
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
34 of 70 03/21/2016 03:06 PM
![Page 35: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/35.jpg)
What's a branch?
A parallel path of development, starting from a committhat's in the tree
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
35 of 70 03/21/2016 03:06 PM
![Page 36: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/36.jpg)
Making a branch
# track remote branch by default if one matches$ git checkout -b <branchname>
# Shorthand for:$ git branch <branchname> # create$ git checkout <branchname> # check out
# Pushing a branch to a remote$ git push <remotename> <branchname>
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
36 of 70 03/21/2016 03:06 PM
![Page 37: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/37.jpg)
Looking at branches
$ git branch
$ git show <branchname>
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
37 of 70 03/21/2016 03:06 PM
![Page 38: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/38.jpg)
Undo?
# delete only if fully merged$ git branch -d
# Delete, I Don't care what I lose$ git branch -D
# delete remote branch$ git push <remotename> :<branchname>
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
38 of 70 03/21/2016 03:06 PM
![Page 39: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/39.jpg)
Imagine...Someone else could work on the same repo in aparallel universe
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
39 of 70 03/21/2016 03:06 PM
![Page 40: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/40.jpg)
What's a remote?
Another clone of more or less thesame repo
(remember when we cloned to get acopy?)
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
40 of 70 03/21/2016 03:06 PM
![Page 41: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/41.jpg)
Adding a Remote
$ man git-remote
$ git remote add <name> <url>
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
41 of 70 03/21/2016 03:06 PM
![Page 42: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/42.jpg)
Looking at Remotes
$ git config -e
# OR
$ git remote show <name>
From one of my git configs...
[remote "origin"]url = [email protected]:monte-language/monte.gitfetch = +refs/heads/*:refs/remotes/origin/*
[remote "edunham"]url = [email protected]:edunham/monte.gitfetch = +refs/heads/*:refs/remotes/edunham/*
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
42 of 70 03/21/2016 03:06 PM
![Page 43: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/43.jpg)
Undo?
Do you prefer text editor...
$ git config -e# delete or change remote
... or commands?
$ man git-remote$ git remote rename <old> <new>$ git remote remove <name>
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
43 of 70 03/21/2016 03:06 PM
![Page 44: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/44.jpg)
What's a merge?
Brings changes from one branch to another
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
44 of 70 03/21/2016 03:06 PM
![Page 45: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/45.jpg)
Making a Merge
# Branch you're changing$ git checkout mywork
$ git merge master
# Merge conflicts?$ git status On branch mywork You have unmerged paths.
(fix conflicts and run "git commit")
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
45 of 70 03/21/2016 03:06 PM
![Page 46: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/46.jpg)
Merge Conflicts
<<<<<<< HEADThis content was in mywork but not master=======This content was in master but not mywork>>>>>>> master
Replace all that stuff with what the content should be.
git add the file.
Check that you've got everything with git status, thencommit.
Or consider git mergetool for an interactive option.
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
46 of 70 03/21/2016 03:06 PM
![Page 47: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/47.jpg)
Looking at Merges
$ git diff <commit before> <merge commit>
# before merging, see changes$ git log ..otherbranch$ git diff ...otherbranch$ gitk ...otherbranch
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
47 of 70 03/21/2016 03:06 PM
![Page 48: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/48.jpg)
Undo?
$ git merge abort$ git reset --keep HEAD@{1}
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
48 of 70 03/21/2016 03:06 PM
![Page 49: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/49.jpg)
What's a rebase?
Changing history. Means others will have to force pull.
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
49 of 70 03/21/2016 03:06 PM
![Page 50: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/50.jpg)
Rebasing
$ git rebase -i <commit range> HEAD~4
# last 4 commits
# Oops I forgot to pull$ git pull --rebase
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
50 of 70 03/21/2016 03:06 PM
![Page 51: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/51.jpg)
Looking at the rebase
# Rebase 1a20f51..147c812 onto 1a20f51## Commands:# p, pick = use commit# r, reword = use commit, but edit the commit message# e, edit = use commit, but stop for amending# s, squash = use commit, but meld into previous commit# f, fixup = like "squash", but discard this commit's log message# x, exec = run command (the rest of the line) using shell## These lines can be re-ordered; they are executed from top to bottom.## If you remove a line here THAT COMMIT WILL BE LOST.
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
51 of 70 03/21/2016 03:06 PM
![Page 52: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/52.jpg)
Undo?
I should never have done that
$ git reset --hard ORIG_HEAD
I'm stuck in a broken rebase, get me out
$ git rebase --abort
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
52 of 70 03/21/2016 03:06 PM
![Page 53: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/53.jpg)
GitHub
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
53 of 70 03/21/2016 03:06 PM
![Page 54: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/54.jpg)
Not Exactly Git
Less distributed paradigm
Git never told us who to trust
Git doesn't care who you are
Watch Linus's talk for more detail
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
54 of 70 03/21/2016 03:06 PM
![Page 55: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/55.jpg)
Getting Started
https://github.com/join
Use the same email as your git config
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
55 of 70 03/21/2016 03:06 PM
![Page 56: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/56.jpg)
HTTP vs SSH Clones
Permission denied (publickey).fatal: Could not read from remoterepository.
Please make sure you have thecorrect access rights and therepository exists.
HTTP clone prompts for username and password
SSH clone uses key from your account
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
56 of 70 03/21/2016 03:06 PM
![Page 57: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/57.jpg)
Forking
Parallel repos (or possibly divergent)
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
57 of 70 03/21/2016 03:06 PM
![Page 58: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/58.jpg)
Pull Requests
Formalizes "Hi, please merge my changes"
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
58 of 70 03/21/2016 03:06 PM
![Page 59: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/59.jpg)
Annoying Tricks
Branches keep adding their content to PRs
Group management and access rights
No project license required
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
59 of 70 03/21/2016 03:06 PM
![Page 60: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/60.jpg)
Extra Features
Wiki
Gist
Issue trackers
Graphs
Repo descriptions and automatic README display
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
60 of 70 03/21/2016 03:06 PM
![Page 61: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/61.jpg)
Additional GitHub tricks
.github/CONTRIBUTING.md
.github/ISSUE_TEMPLATE.md
.github/PULL_REQUEST_TEMPLATE.md
README
Display test results on PRs
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
61 of 70 03/21/2016 03:06 PM
![Page 62: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/62.jpg)
Continuous Integration
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
62 of 70 03/21/2016 03:06 PM
![Page 63: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/63.jpg)
Playing Well With Others
Change history locally, never globallyNever force push (unless you have to)
Focused commits with clear commit messages
Follow project standards for branching, tagging, etc.
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
63 of 70 03/21/2016 03:06 PM
![Page 64: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/64.jpg)
Questions?
Emily Dunham
edunham on irc.freenode.net
@qedunham
talks.edunham.net/gwo2016/git
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
64 of 70 03/21/2016 03:06 PM
![Page 65: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/65.jpg)
Other Stuff
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
65 of 70 03/21/2016 03:06 PM
![Page 66: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/66.jpg)
checkout
$ git checkout branch
point HEAD at the tip of the specified branch
$ git checkout <revision> file
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
66 of 70 03/21/2016 03:06 PM
![Page 67: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/67.jpg)
gitrevisions
$ man gitrevisions
Commit hash
RefnameHEAD^n is nth parent of tip of current branch
branchname~n is nth generation ancestor of thatbranch
Regex on commit message * :/broken
revision:path
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
67 of 70 03/21/2016 03:06 PM
![Page 68: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/68.jpg)
git bisect
Binary Search:
git bisect startgit bisect bad <commit>git bisect good <commit>git bisect nextgit bisect reset <commit>
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
68 of 70 03/21/2016 03:06 PM
![Page 69: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/69.jpg)
git cherry-pick
$ git checkout <branch that needs special commit>$ git cherry-pick <special commit from another branch>
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
69 of 70 03/21/2016 03:06 PM
![Page 70: Thinking in Git](https://reader035.fdocuments.us/reader035/viewer/2022062503/587edc621a28abdb198b76cf/html5/thumbnails/70.jpg)
git format-patch
$ git format-patch origin/master0001-first-commit.patch0002-second-commit.patch
# I wonder what this patch does$ git apply --stat 0001-first-commit.patch
# Let's merge!$ git apply 0001-first-commit.patch
# Does your project use signed-off-by?$ git am --signoff < 0001-first-commit.patch
Thinking in Git — Thinking in Git documentation http://talks.edunham.net/gwo2016/git/slides/#1
70 of 70 03/21/2016 03:06 PM