Slide 1

Slide 1 text

LLNL-PRES-698283 This work was performed under the auspices of the U.S. Department of Energy by Lawrence Livermore National Laboratory under contract DE-AC52-07NA27344. Lawrence Livermore National Security, LLC Introduc)on to Git Ian Lee [email protected] July 25, 2016

Slide 2

Slide 2 text

LLNL-PRES-698283 2 §  git --version —  2.9.2 §  Opera7ng System —  OS X / Linux §  Markdown / Unix Inspired Style FormaEng —  $ shell prompt command —  `code` —  —  [OPTIONAL PARAMETER] —  `$ foo [bar] ` Define your terms

Slide 3

Slide 3 text

LLNL-PRES-698283 3 What is version control? http://smutch.github.io/VersionControlTutorial/

Slide 4

Slide 4 text

LLNL-PRES-698283 4 Common Version Control Tools

Slide 5

Slide 5 text

LLNL-PRES-698283 5 Fear of Git If that doesn't fix it, git.txt contains the phone number of a friend of mine who understands git. Just wait through a few minutes of 'It's really pre=y simple, just think of branches as...' and eventually you'll learn the commands that will fix everything. h_ps://xkcd.com/1597/

Slide 6

Slide 6 text

LLNL-PRES-698283 6 §  Required —  $ git config --global user.name “Ian Lee” —  $ git config --global user.email “[email protected]” §  Op7onal (but recommended) —  $ git config --global color.ui true —  $ git config --global creden7al.helper “cache --7meout=43200” —  $ git config --global push.default simple §  For this course —  $ git config --global core.pager cat §  More informa7on —  h_ps://myconfluence.llnl.gov/display/GIT/Git+Config Configuring Git: `man git-config`

Slide 7

Slide 7 text

LLNL-PRES-698283 7 Crea)ng a new repo: `git init`

Slide 8

Slide 8 text

LLNL-PRES-698283 8 Seeing what’s changed: `git status`

Slide 9

Slide 9 text

LLNL-PRES-698283 9 Tracking a new file: `git add `

Slide 10

Slide 10 text

LLNL-PRES-698283 10 Ini)al commit: `git commit -m “” `

Slide 11

Slide 11 text

LLNL-PRES-698283 11 Making changes: `git diff [] [--] [<filename>]`

Slide 12

Slide 12 text

LLNL-PRES-698283 12 Making changes: `git diff [] [--] [<filename>]`

Slide 13

Slide 13 text

LLNL-PRES-698283 13 CommiSng All Changes: `git commit -a -m””`

Slide 14

Slide 14 text

LLNL-PRES-698283 14 Staged vs not staged vs untracked

Slide 15

Slide 15 text

LLNL-PRES-698283 15 Good Commit Messages Merge branch 'asdfasjkfdlas/alkdjf' into sdkjfls-final h_ps://xkcd.com/1296/

Slide 16

Slide 16 text

LLNL-PRES-698283 16 Visualizing Changes: `git show [reference]`

Slide 17

Slide 17 text

LLNL-PRES-698283 17 Visualizing Changes: `git show [reference]`

Slide 18

Slide 18 text

LLNL-PRES-698283 18 Visualizing Changes: `git log`

Slide 19

Slide 19 text

LLNL-PRES-698283 19 Visualizing Changes: `git log --stat`

Slide 20

Slide 20 text

LLNL-PRES-698283 20 Visualizing Changes: `git log` - advanced

Slide 21

Slide 21 text

LLNL-PRES-698283 21 Visualizing Changes: `)g`

Slide 22

Slide 22 text

LLNL-PRES-698283 22 Visualizing Changes: `gitk [--all]`

Slide 23

Slide 23 text

LLNL-PRES-698283 23 Making Mistakes

Slide 24

Slide 24 text

LLNL-PRES-698283 24 Making Mistakes

Slide 25

Slide 25 text

LLNL-PRES-698283 25 Discarding Changes: `git checkout [reference] -- `

Slide 26

Slide 26 text

LLNL-PRES-698283 26 Doing some work

Slide 27

Slide 27 text

LLNL-PRES-698283 27 Doing some work

Slide 28

Slide 28 text

LLNL-PRES-698283 28 Star)ng to branch out: `git checkout -b `

Slide 29

Slide 29 text

LLNL-PRES-698283 29 Star)ng to branch out: `git checkout -b `

Slide 30

Slide 30 text

LLNL-PRES-698283 30 Star)ng to branch out: `git checkout -b `

Slide 31

Slide 31 text

LLNL-PRES-698283 31 Branches (and tags) are like s)cky notes

Slide 32

Slide 32 text

LLNL-PRES-698283 32 Branches: `git branch`

Slide 33

Slide 33 text

LLNL-PRES-698283 33 Renaming a branch: `git branch -m `

Slide 34

Slide 34 text

LLNL-PRES-698283 34 Crea)ng new branches: `git branch `

Slide 35

Slide 35 text

LLNL-PRES-698283 35 Crea)ng new branches: `git branch `

Slide 36

Slide 36 text

LLNL-PRES-698283 36 Switching branches: `git checkout `

Slide 37

Slide 37 text

LLNL-PRES-698283 37 Tangent: The “HEAD” branch

Slide 38

Slide 38 text

LLNL-PRES-698283 38 Dele)ng branches: `git branch -d `

Slide 39

Slide 39 text

LLNL-PRES-698283 39 REALLY dele)ng branches: `git branch -D `

Slide 40

Slide 40 text

LLNL-PRES-698283 40 Working on Master

Slide 41

Slide 41 text

LLNL-PRES-698283 41 Divergence when working on mul)ple branches

Slide 42

Slide 42 text

LLNL-PRES-698283 42 Merging branches: `git merge `

Slide 43

Slide 43 text

LLNL-PRES-698283 43 Undo: `git reset --hard `

Slide 44

Slide 44 text

LLNL-PRES-698283 44 Undo: `git reset `

Slide 45

Slide 45 text

LLNL-PRES-698283 45 Undo: `git reset `

Slide 46

Slide 46 text

LLNL-PRES-698283 46 Current State: We’ll come back to this...

Slide 47

Slide 47 text

LLNL-PRES-698283 47 Working with remotes

Slide 48

Slide 48 text

LLNL-PRES-698283 48 Finding something to contribute to: Atlassian BitBucket

Slide 49

Slide 49 text

LLNL-PRES-698283 49 Finding something to contribute to: GitHub

Slide 50

Slide 50 text

LLNL-PRES-698283 50 Star)ng from exis)ng: `git clone `

Slide 51

Slide 51 text

LLNL-PRES-698283 51 Lis)ng the remotes: `git remote -v`

Slide 52

Slide 52 text

LLNL-PRES-698283 52 master vs origin/master

Slide 53

Slide 53 text

LLNL-PRES-698283 53 Adding a remote: `git remote add `

Slide 54

Slide 54 text

LLNL-PRES-698283 54 Where is origin-ssh?

Slide 55

Slide 55 text

LLNL-PRES-698283 55 Fetching remotes: `git fetch `

Slide 56

Slide 56 text

LLNL-PRES-698283 56 master vs origin/master vs origin-ssh/master

Slide 57

Slide 57 text

LLNL-PRES-698283 57 ForgeSng a remote: `git remote rm `

Slide 58

Slide 58 text

LLNL-PRES-698283 58 Crea)ng something new: `git checkout -b `

Slide 59

Slide 59 text

LLNL-PRES-698283 59 Crea)ng something new: `git checkout -b `

Slide 60

Slide 60 text

LLNL-PRES-698283 60 Contribu)ng back: `git push --set-upstream `

Slide 61

Slide 61 text

LLNL-PRES-698283 61 Contribu)ng back: `git push --set-upstream `

Slide 62

Slide 62 text

LLNL-PRES-698283 62 Merging to remote branches

Slide 63

Slide 63 text

LLNL-PRES-698283 63 Pushing to master: `git push [ ]`

Slide 64

Slide 64 text

LLNL-PRES-698283 64 Trimming branches: `git push --delete `

Slide 65

Slide 65 text

LLNL-PRES-698283 65 Trimming branches: `git push --delete `

Slide 66

Slide 66 text

LLNL-PRES-698283 66 Git Flow https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow

Slide 67

Slide 67 text

LLNL-PRES-698283 67 Git Flow: Main Branches https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow

Slide 68

Slide 68 text

LLNL-PRES-698283 68 Git Flow: Feature Branches https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow

Slide 69

Slide 69 text

LLNL-PRES-698283 69 Git Flow: Release Branches https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow

Slide 70

Slide 70 text

LLNL-PRES-698283 70 Git Flow: Maintenance Branches https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow

Slide 71

Slide 71 text

LLNL-PRES-698283 71 §  Git Confluence Space —  h_ps://myconfluence.llnl.gov/display/git §  Git Tutorials —  h_ps://try.github.io/ —  h_p://learngitbranching.js.org/ —  h_ps://www.atlassian.com/git/ §  Commandline help —  $ man git —  $ git –help §  This talk —  h_ps://speakerdeck.com/ianlee1521/introduc7on-to-git GeSng Help

Slide 72

Slide 72 text

Questions? $ cat git.txt Ian Lee – [email protected]