Slide 1

Slide 1 text

Git In It BEGINNING TO USE GIT John Kary johnkary@ gmail.com @ johnkary Slides @ http://johnkary.net/talks

Slide 2

Slide 2 text

Overview • Getting over the hurdle • Setting up your environment • Your first repository • Invest

Slide 3

Slide 3 text

Part 1 Getting over the hurdle Source: http://www.flickr.com/photos/keokiseu/4620268471/

Slide 4

Slide 4 text

pre post

Slide 5

Slide 5 text

git

Slide 6

Slide 6 text

Chad Dickerson CEO @ Etsy RailsConf 2011 Keynote http://codeascraft.etsy.com/2011/06/06/optimizing-for-developer-happiness/ Optimize for developer happiness. “ ”

Slide 7

Slide 7 text

Excuses

Slide 8

Slide 8 text

I keep backups.

Slide 9

Slide 9 text

No, really, I keep backups.

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

+ Automagically syncs + Cloud! + Distributed + Built-in versioning - Not searchable by contents - Not easy to experiment and roll-back - No diff-view between versions - No version metadata - Saved versions for only last 30 days Dropbox versioning is...

Slide 12

Slide 12 text

is Versioning NOT Version-Control

Slide 13

Slide 13 text

I’ve tried _____

Slide 14

Slide 14 text

I’ve tried _____

Slide 15

Slide 15 text

I’ve tried _____

Slide 16

Slide 16 text

I’ve tried _____

Slide 17

Slide 17 text

I’ve tried _____

Slide 18

Slide 18 text

I’ve tried _____ it gets in the way of getting real work done

Slide 19

Slide 19 text

Photo: Jesse D. Garrabrant/NBAE via Getty Images The Truth Is... Learning git is an Investment It becomes second nature Accomplish More Work Faster Jump Higher

Slide 20

Slide 20 text

Has anyone started using version control recently?

Slide 21

Slide 21 text

Part 2 Setting up your environment Source: http://www.flickr.com/photos/akahodag/3753216775/

Slide 22

Slide 22 text

Install git http://git-scm.com/downloads

Slide 23

Slide 23 text

Setup git https://help.github.com/articles/set-up-git

Slide 24

Slide 24 text

Install git - Mac ~ $ brew install git ... ~ $ which git /usr/local/bin/git Homebrew The missing package manager for OS X http://mxcl.github.com/homebrew/

Slide 25

Slide 25 text

Install git - Mac ~ $ man git-log GIT-LOG(1) Git Manual GIT-LOG(1) NAME git-log - Show commit logs SYNOPSIS git log [] [..] [[--] ...] DESCRIPTION Shows the commit logs. The command takes options applicable to the git rev-list command to control what is shown and how, and options applicable to the git Easy man page access

Slide 26

Slide 26 text

Install git - Mac ~ $ cat ~/.bash_profile source `brew --prefix git`/etc/bash_completion.d/git-completion.bash ~ $ source ~/.bash_profile ~ $ git sta stage stash status ~ $ git sta Bash command auto-completion

Slide 27

Slide 27 text

Interacting with your repository

Slide 28

Slide 28 text

For those already using git... Who is using a GUI?

Slide 29

Slide 29 text

For those already using git... Who is using a CLI?

Slide 30

Slide 30 text

git tower - http://www.git-tower.com

Slide 31

Slide 31 text

Gitbox - http://www.gitboxapp.com/

Slide 32

Slide 32 text

github for mac - http://mac.github.com/

Slide 33

Slide 33 text

github for Windows - http://windows.github.com/

Slide 34

Slide 34 text

Strongly STRONGLY encourage you to NOT use a GUI

Slide 35

Slide 35 text

git GUIs • Dumb-down underlying commands • Present limited command options • Not available on most remote servers • But there is one I recommend...

Slide 36

Slide 36 text

GitX - http://brotherbard.com/blog/2010/03/experimental-gitx-fork/

Slide 37

Slide 37 text

GitX - http://brotherbard.com/blog/2010/03/experimental-gitx-fork/ (master) ~/Sites/mysite $ gitx

Slide 38

Slide 38 text

~ $ git config --global alias.lola "log --graph --decorate >> --pretty=oneline --abbrev-commit --all" (master) ~/Sites/mysite $ git lola git log-one-line --all (lola) Useful when on a remote sever

Slide 39

Slide 39 text

Customizing your shell

Slide 40

Slide 40 text

PS1 ~ $ cat ~/.bash_profile source `brew --prefix git`/etc/bash_completion.d/git-completion.bash export PS1="\[\e[0;34m\]\$(__git_ps1) \[\e[0;31m\]\w \[\e[0m\]$ " (master) ~/Sites/mysite $ git checkout 9d9bc29 Note: checking out '9d9bc29'. You are in 'detached HEAD' state. You can look around, make experimental ... ((9d9bc29...)) ~/Sites/mysite $

Slide 41

Slide 41 text

Part 3 Your first repository Source: http://www.flickr.com/photos/nathaninsandiego/2584256116/

Slide 42

Slide 42 text

Your first repository ~/Sites/beginning $ ls -la total 16 drwxr-xr-x 4 johnkary staff 136 Jun 26 10:43 . drwxr-xr-x+ 113 johnkary staff 3842 Jun 26 10:42 .. -rw-r--r-- 1 johnkary staff 90 Jun 26 10:42 README -rw-r--r--@ 1 johnkary staff 210 Jun 26 10:44 index.html

Slide 43

Slide 43 text

Your first repository ~/Sites/beginning $ git init Initialized empty Git repository in /Users/johnkary/Sites/beginning/.git/ (master) ~/Sites/beginning $ Create a git repository (master) ~/Sites/beginning $ ls -la total 16 drwxr-xr-x 5 johnkary staff 170 Jun 26 10:50 . drwxr-xr-x+ 113 johnkary staff 3842 Jun 26 10:42 .. drwxr-xr-x 9 johnkary staff 306 Jun 26 10:50 .git -rw-r--r-- 1 johnkary staff 90 Jun 26 10:42 README -rw-r--r--@ 1 johnkary staff 210 Jun 26 10:44 index.html

Slide 44

Slide 44 text

Your first repository (master) ~/Sites/beginning $ git add README (master) ~/Sites/beginning $ git status # On branch master # # Initial commit # # Changes to be committed: # (use "git rm --cached ..." to unstage) # # new file: README # # Untracked files: # (use "git add ..." to include in what will be committed) # # index.html Add a file to be committed

Slide 45

Slide 45 text

Your first repository Source: http://git-scm.com/about/staging-area

Slide 46

Slide 46 text

Your first repository (master) ~/Sites/beginning $ git commit -m "Add README" [master (root-commit) 4f6d22d] Add README 1 file changed, 5 insertions(+) create mode 100644 README Commit our change (master) ~/Sites/beginning $ git status # On branch master # Untracked files: # (use "git add ..." to include in what will be committed) # # index.html nothing added to commit but untracked files present (use "git add" to track)

Slide 47

Slide 47 text

Your first repository (master) ~/Sites/beginning $ git add index.html (master) ~/Sites/beginning $ git commit -m "Add prototype" [master 478eb5a] Add prototype 1 file changed, 11 insertions(+) create mode 100644 index.html Commit our initial project prototype (master) ~/Sites/beginning $ git status # On branch master nothing to commit (working directory clean)

Slide 48

Slide 48 text

Your first repository (master) ~/Sites/beginning $ git log commit 478eb5a19fbd7fe7574942db285e0b2dff43fa85 Author: John Kary Date: Tue Jun 26 11:19:30 2012 -0500 Add prototype commit 4f6d22d25f8a59163c45e506cb0f8ecadcf918d0 Author: John Kary Date: Tue Jun 26 11:10:35 2012 -0500 Add README View your commit history

Slide 49

Slide 49 text

Your first repository commit 478eb5a19fbd7fe7574942db285e0b2dff43fa85 Author: John Kary Date: Tue Jun 26 11:19:30 2012 -0500 Add prototype (master) ~/Sites/beginning $ git commit -m "Add prototype" [master 478eb5a] Add prototype 1 file changed, 11 insertions(+) create mode 100644 index.html Git SHA-1’s

Slide 50

Slide 50 text

Your first repository commit 478eb5a19fbd7fe7574942db285e0b2dff43fa85 Author: John Kary Date: Tue Jun 26 11:19:30 2012 -0500 Add prototype (master) ~/Sites/beginning $ git commit -m "Add prototype" [master 478eb5a] Add prototype 1 file changed, 11 insertions(+) create mode 100644 index.html (master) ~/Sites/beginning $ git cat-file -p 478eb5a19fbd7fe7574942db285e0b2dff43fa85 tree d7709a57c4668831d09bbbf69c7f1410ddeeae03 parent 4f6d22d25f8a59163c45e506cb0f8ecadcf918d0 author John Kary 1340727570 -0500 committer John Kary 1340727570 -0500 Add prototype Git SHA-1’s

Slide 51

Slide 51 text

Your first repository More changes (master) ~/Sites/beginning $ git diff diff --git a/index.html b/index.html index edff44b..0765008 100644 --- a/index.html +++ b/index.html @@ -2,10 +2,10 @@ - My new project + Drupal KC -

My new project

+

Drupal KC

This project will change your life!

Slide 52

Slide 52 text

Your first repository More changes (master) ~/Sites/beginning $ git add index.html (master) ~/Sites/beginning $ git status # On branch master # Changes to be committed: # (use "git reset HEAD ..." to unstage) # # modified: index.html # (master) ~/Sites/beginning $ git commit -m "Name project Drupal KC This is John's first idea for the project's name. Will be revising it as we go forward." [master 467350d] Name project Drupal KC 1 file changed, 2 insertions(+), 2 deletions(-)

Slide 53

Slide 53 text

Your first repository More changes (master) ~/Sites/beginning $ git log --oneline 467350d Name project Drupal KC 478eb5a Add prototype 4f6d22d Add README

Slide 54

Slide 54 text

Your first repository (master) ~/Sites/beginning $ gitx

Slide 55

Slide 55 text

Your first repository (master) ~/Sites/beginning $ vim index.html (master) ~/Sites/beginning $ git diff diff --git a/index.html b/index.html index 0765008..a2bf6bf 100644 --- a/index.html +++ b/index.html @@ -6,6 +6,10 @@

Drupal KC

+ +

About this project

This project will change your life!

+ +
Drupal KC

Slide 56

Slide 56 text

Your first repository git add -p

Slide 57

Slide 57 text

Your first repository (master) ~/Sites/beginning $ git add -p diff --git a/index.html b/index.html index 0765008..a2bf6bf 100644 --- a/index.html +++ b/index.html @@ -6,6 +6,10 @@

Drupal KC

+ +

About this project

This project will change your life!

+ +
Drupal KC
Stage this hunk [y,n,q,a,d,/,s,e,?]? s

Slide 58

Slide 58 text

Your first repository Split into 2 hunks. @@ -6,4 +6,6 @@

Drupal KC

+ +

About this project

This project will change your life!

Stage this hunk [y,n,q,a,d,/,j,J,g,e,?]? y

Slide 59

Slide 59 text

Your first repository Split into 2 hunks. @@ -6,4 +6,6 @@

Drupal KC

+ +

About this project

This project will change your life!

Stage this hunk [y,n,q,a,d,/,j,J,g,e,?]? y @@ -9,3 +11,5 @@

This project will change your life!

+ +
Drupal KC
Stage this hunk [y,n,q,a,d,/,K,g,e,?]? n

Slide 60

Slide 60 text

Your first repository (master) ~/Sites/beginning $ git status # On branch master # Changes to be committed: # (use "git reset HEAD ..." to unstage) # # modified: index.html # # Changes not staged for commit: # (use "git add ..." to update what will be committed) # (use "git checkout -- ..." to discard changes in working directory) # # modified: index.html # (master) ~/Sites/beginning $ git commit -m “Add about heading” [master c580363] Add about heading 1 file changed, 2 insertions(+)

Slide 61

Slide 61 text

Your first repository (master) ~/Sites/beginning $ git add -p diff --git a/index.html b/index.html index 85a10ca..a2bf6bf 100644 --- a/index.html +++ b/index.html @@ -9,5 +9,7 @@

About this project

This project will change your life!

+ +
Drupal KC
Stage this hunk [y,n,q,a,d,/,e,?]? y (master) ~/Sites/beginning $ git commit -m "Add company logo" [master 671829d] Add company logo 1 file changed, 2 insertions(+)

Slide 62

Slide 62 text

Your first repository (master) ~/Sites/beginning $ git log --oneline 671829d Add company logo c580363 Add about heading 467350d Name project Drupal KC 478eb5a Add prototype 4f6d22d Add README

Slide 63

Slide 63 text

Part 4 Invest Source: http://www.flickr.com/photos/tinavega/2896641451/

Slide 64

Slide 64 text

Invest Official Git Docs http://git-scm.com/doc

Slide 65

Slide 65 text

Invest Git Immersion http://gitimmersion.com

Slide 66

Slide 66 text

Invest http://git-scm.com/book http://pragprog.com/book/tsgit/ pragmatic-version-control-using-git

Slide 67

Slide 67 text

Invest Getting Git By Scott Chacon http://blip.tv/scott-chacon/git-talk-4113729 Source: http://www.flickr.com/photos/fraserspeirs/3389758506/

Slide 68

Slide 68 text

START

Slide 69

Slide 69 text

Optimize for developer happiness - http://codeascraft.etsy.com/2011/06/06/optimizing-for-developer-happiness/ Homebrew - http://mxcl.github.com/homebrew/ git tower - http://www.git-tower.com/ Gitbox - http://www.gitboxapp.com/ github for mac - http://mac.github.com/ GitX - http://brotherbard.com/blog/2010/03/experimental-gitx-fork/ Official Git Docs - http://git-scm.com/doc Git Immersion - http://gitimmersion.com Pro Git - http://git-scm.com/book Pragmatic Version Control Using Git - http://pragprog.com/book/tsgit/pragmatic-version-control-using-git Getting git by Scott Chacon - http://blip.tv/scott-chacon/git-talk-4113729 Slides - http://johnkary.net/talks Resources

Slide 70

Slide 70 text

Git In It BEGINNING TO USE GIT John Kary johnkary@ gmail.com @ johnkary Slides @ http://johnkary.net/talks