753
Git 101 Scott Chacon

Git 101 tutorial presentation

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Git 101 tutorial presentation

Git 101Scott Chacon

Page 2: Git 101 tutorial presentation

Introduction

Page 3: Git 101 tutorial presentation

Me

Page 4: Git 101 tutorial presentation

Scott Chacon

Page 5: Git 101 tutorial presentation
Page 6: Git 101 tutorial presentation

git-scm.com

Page 7: Git 101 tutorial presentation

http://gitref.org

Page 8: Git 101 tutorial presentation
Page 9: Git 101 tutorial presentation

http://progit.org

Page 11: Git 101 tutorial presentation

@chacontwitter

Page 12: Git 101 tutorial presentation

</me>

Page 13: Git 101 tutorial presentation

What is Git?

Page 14: Git 101 tutorial presentation

“distributed version control system”

Page 15: Git 101 tutorial presentation

what is version control?

Page 16: Git 101 tutorial presentation

what is version control?what do we use it for?

Page 17: Git 101 tutorial presentation

imagine a world with no version control tools

Page 18: Git 101 tutorial presentation
Page 19: Git 101 tutorial presentation

what would you do?

Page 20: Git 101 tutorial presentation

downsides?

Page 21: Git 101 tutorial presentation

who doesn’t use version control?

Page 22: Git 101 tutorial presentation

who doesn’t use version control?

rhetorical question

Page 23: Git 101 tutorial presentation

what project is this?• thousands of developers

• working all across the world

• used on millions of computers

• runs 90% of the supercomputers in the world

• runs my phone

• 11 years with no version control system

• has an adorable mascot

Page 24: Git 101 tutorial presentation
Page 25: Git 101 tutorial presentation

1991-2002

Page 26: Git 101 tutorial presentation
Page 27: Git 101 tutorial presentation
Page 28: Git 101 tutorial presentation

no version control

Page 29: Git 101 tutorial presentation

how did they do it?

Page 30: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

Page 31: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

ver-1.0.zip

Page 32: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

ver-1.0.zip

you

Page 33: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

ver-1.0.zip

you

Page 34: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

ver-1.0.zip

you

v1/main.cv1/library.cv1/library.h

Page 35: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

ver-1.0.zip

you

v1/main.cv1/library.cv1/library.h

cp -Rf v1 patch

Page 36: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

ver-1.0.zip

you

v1/main.cv1/library.cv1/library.h

cp -Rf v1 patch

patch/main.cpatch/library.cpatch/library.h

Page 37: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

ver-1.0.zip

you

v1/main.cv1/library.cv1/library.h

cp -Rf v1 patch

patch/main.cpatch/library.cpatch/library.h

Page 38: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

ver-1.0.zip

you

v1/main.cv1/library.cv1/library.h

cp -Rf v1 patch

patch/main.cpatch/library.c*patch/library.h

diff -u v1 patch

Page 39: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

ver-1.0.zip

you

v1/main.cv1/library.cv1/library.h

cp -Rf v1 patch

patch/main.cpatch/library.c*patch/library.h

diff -u v1 patch

$ git diff v1 patchdiff --git a/v1/library.c b/patch/library.cindex 0be4b5f..0120580 100644--- a/v1/library.c+++ b/patch/library.c@@ -19,7 +19,7 @@ static struct { { "detachedhead", &advice_detached_head }, }; -int git_default_config(const char *var, const char *value)+int YO_MOMMA_IS_FAT(const char *var, const char *value) { const char *k = skip_prefix(var, "advice."); int i;

Page 40: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

ver-1.0.zip

you

v1/main.cv1/library.cv1/library.h

cp -Rf v1 patch

patch/main.cpatch/library.c*patch/library.h

diff -u v1 patch

email

Page 41: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

you

v1/main.cv1/library.cv1/library.h

cp -Rf v1 patch

patch/main.cpatch/library.c*patch/library.h

diff -u v1 patch

ver-1.0.zip

ver-1.1.zip

Page 42: Git 101 tutorial presentation

ver-1.0.zip

ver-1.1.zip

ver-1.2.zip

Page 43: Git 101 tutorial presentation

now imagine...

Page 44: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

V1

Page 45: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

you

V1main.clibrary.clibrary.h

V1

Page 46: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

you

V1main.clibrary.clibrary.h

V1

main.clibrary.c*library.h

V2

Page 47: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

you

V1

main.c*library.clibrary.h

V3

main.clibrary.clibrary.h

V1

main.clibrary.c*library.h

V2

Page 48: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

you

V1

main.c*library.clibrary.h

V3

main.clibrary.clibrary.h

V1

main.clibrary.c*library.h

V2main.clibrary.c*library.h

V2

Page 49: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

you

V1

main.c*library.clibrary.h

V3

main.clibrary.clibrary.h

V1

main.clibrary.c*library.h

V2main.clibrary.c*library.h

V2

main.c*library.c*library.h

V4

Page 50: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

you

V1

main.c*library.clibrary.h

V3

main.clibrary.clibrary.h

V1

main.clibrary.c*library.h

V2main.clibrary.c*library.h

V2

main.c*library.c*library.h

V4

Page 51: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

you

V1

main.c*library.clibrary.h

V3

main.clibrary.clibrary.h

V1

main.clibrary.c*library.h

V2main.clibrary.c*library.h

V2

main.c*library.c*library.h

V4

Page 52: Git 101 tutorial presentation

main dude

main.clibrary.clibrary.h

you

V1

main.c*library.clibrary.h

V3

main.clibrary.clibrary.h

V1

main.clibrary.c*library.h

V2main.clibrary.c*library.h

V2

main.c*library.c*library.h

V4

Page 53: Git 101 tutorial presentation

Snapshots, not Patches

Page 54: Git 101 tutorial presentation

deltastorage

snapshotstorage

Page 55: Git 101 tutorial presentation

deltastorage

snapshotstorage

Page 56: Git 101 tutorial presentation

deltastorage

snapshotstorage

Page 57: Git 101 tutorial presentation

deltastorage

snapshotstorage

Page 58: Git 101 tutorial presentation

deltastorage

snapshotstorage

Page 59: Git 101 tutorial presentation

deltastorage

snapshotstorage

Page 60: Git 101 tutorial presentation

deltastorage

snapshotstorage

Page 61: Git 101 tutorial presentation

deltastorage

snapshotstorage

Page 62: Git 101 tutorial presentation

deltastorage

snapshotstorage

Page 63: Git 101 tutorial presentation

deltastorage

snapshotstorage

Page 64: Git 101 tutorial presentation

deltastorage

snapshotstorage

Page 65: Git 101 tutorial presentation

deltastorage

snapshotstorage

Page 66: Git 101 tutorial presentation

deltastorage

snapshotstorage

Page 67: Git 101 tutorial presentation

deltastorage

snapshotstorage

Page 68: Git 101 tutorial presentation

deltastorage

snapshotstorage

Page 69: Git 101 tutorial presentation
Page 70: Git 101 tutorial presentation

Basic Git

Page 71: Git 101 tutorial presentation

First Steps

Page 72: Git 101 tutorial presentation

$ git config --global user.name “Scott Chacon”

$ git config --global user.email “[email protected]

Page 73: Git 101 tutorial presentation

Getting a Repo

Page 74: Git 101 tutorial presentation

Create One

Page 75: Git 101 tutorial presentation

git init

Page 76: Git 101 tutorial presentation

$ touch hello_world.rb$ git init$ git add .$ git commit -m ‘first commit’

Page 77: Git 101 tutorial presentation

$ touch hello_world.rb$ git init$ git add .$ git commit -m ‘first commit’

Page 78: Git 101 tutorial presentation

$ tree -a.|-- .git| |-- HEAD| |-- branches| |-- config| |-- description| |-- hooks| | |-- post-commit.sample| | |-- post-receive.sample| | |-- ...| | |-- pre-rebase.sample| | `-- update.sample| |-- info| | `-- exclude| |-- objects| | |-- info| | `-- pack| |-- refs| | |-- heads| | `-- tags| `-- remotes`-- hello_world.rb

11 directories, 25 files

Page 79: Git 101 tutorial presentation

$ tree -a.|-- .git| |-- HEAD| |-- branches| |-- config| |-- description| |-- hooks| | |-- post-commit.sample| | |-- post-receive.sample| | |-- ...| | |-- pre-rebase.sample| | `-- update.sample| |-- info| | `-- exclude| |-- objects| | |-- info| | `-- pack| |-- refs| | |-- heads| | `-- tags| `-- remotes`-- hello_world.rb

11 directories, 25 files

Page 80: Git 101 tutorial presentation

$ tree -a.|-- .git| |-- HEAD| |-- branches| |-- config| |-- description| |-- hooks| | |-- post-commit.sample| | |-- post-receive.sample| | |-- ...| | |-- pre-rebase.sample| | `-- update.sample| |-- info| | `-- exclude| |-- objects| | |-- info| | `-- pack| |-- refs| | |-- heads| | `-- tags| `-- remotes`-- hello_world.rb

11 directories, 25 files

Page 81: Git 101 tutorial presentation

$ touch hello_world.rb$ git init$ git add .$ git commit -m ‘first commit’

Page 82: Git 101 tutorial presentation

$ touch hello_world.rb$ git init$ git add .$ git commit -m ‘first commit’

Page 83: Git 101 tutorial presentation

$ tree -a.|-- .git| |-- COMMIT_EDITMSG| |-- HEAD| |-- branches| |-- config| |-- description| |-- hooks| | |-- applypatch-msg.sample| | `-- update.sample| |-- index| |-- info| | `-- exclude| |-- logs| | |-- HEAD| | `-- refs| | `-- heads| | `-- master| |-- objects| | |-- 32/09658ac8d80bc9726d3a33d77e3dfc5fe6035e| | |-- 53/9cd7886a627841d525a78d45cbc6396be20b41| | |-- e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391| | |-- info| | `-- pack| |-- refs| | |-- heads| | | `-- master| | `-- tags| `-- remotes`-- hello_world.rb

17 directories, 33 files

Page 84: Git 101 tutorial presentation

$ tree -a.|-- .git| |-- COMMIT_EDITMSG| |-- HEAD| |-- branches| |-- config| |-- description| |-- hooks| | |-- applypatch-msg.sample| | `-- update.sample| |-- index| |-- info| | `-- exclude| |-- logs| | |-- HEAD| | `-- refs| | `-- heads| | `-- master| |-- objects| | |-- 32/09658ac8d80bc9726d3a33d77e3dfc5fe6035e| | |-- 53/9cd7886a627841d525a78d45cbc6396be20b41| | |-- e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391| | |-- info| | `-- pack| |-- refs| | |-- heads| | | `-- master| | `-- tags| `-- remotes`-- hello_world.rb

17 directories, 33 files

Page 85: Git 101 tutorial presentation

$ tree -a.|-- .git| |-- COMMIT_EDITMSG| |-- HEAD| |-- branches| |-- config| |-- description| |-- hooks| | |-- applypatch-msg.sample| | `-- update.sample| |-- index| |-- info| | `-- exclude| |-- logs| | |-- HEAD| | `-- refs| | `-- heads| | `-- master| |-- objects| | |-- 32/09658ac8d80bc9726d3a33d77e3dfc5fe6035e| | |-- 53/9cd7886a627841d525a78d45cbc6396be20b41| | |-- e6/9de29bb2d1d6434b8b29ae775ad8c2e48c5391| | |-- info| | `-- pack| |-- refs| | |-- heads| | | `-- master| | `-- tags| `-- remotes`-- hello_world.rb

17 directories, 33 files

Page 86: Git 101 tutorial presentation

Clone One

Page 87: Git 101 tutorial presentation

git clone

Page 88: Git 101 tutorial presentation

$ git clone git://github.com/schacon/ticgit.gitInitialized empty Git repository in /private/tmp/ticgit/.git/remote: Counting objects: 591, done.remote: Compressing objects: 100% (267/267), done.remote: Total 591 (delta 253), reused 587 (delta 252)Receiving objects: 100% (591/591), 73.05 KiB, done.Resolving deltas: 100% (253/253), done.$ cd ticgit/$ lsLICENSE! ! Rakefile! examples! note! ! ticgit.gemspecREADME!! bin!! lib!! spec$

Page 89: Git 101 tutorial presentation

$ git clone git://github.com/schacon/ticgit.gitInitialized empty Git repository in /private/tmp/ticgit/.git/remote: Counting objects: 591, done.remote: Compressing objects: 100% (267/267), done.remote: Total 591 (delta 253), reused 587 (delta 252)Receiving objects: 100% (591/591), 73.05 KiB, done.Resolving deltas: 100% (253/253), done.$ cd ticgit/$ lsLICENSE! ! Rakefile! examples! note! ! ticgit.gemspecREADME!! bin!! lib!! spec$

Page 90: Git 101 tutorial presentation

$ git clone git://github.com/schacon/ticgit.gitInitialized empty Git repository in /private/tmp/ticgit/.git/remote: Counting objects: 591, done.remote: Compressing objects: 100% (267/267), done.remote: Total 591 (delta 253), reused 587 (delta 252)Receiving objects: 100% (591/591), 73.05 KiB, done.Resolving deltas: 100% (253/253), done.$ cd ticgit/$ lsLICENSE! ! Rakefile! examples! note! ! ticgit.gemspecREADME!! bin!! lib!! spec$

Page 91: Git 101 tutorial presentation

$ git clone git://github.com/schacon/ticgit.gitInitialized empty Git repository in /private/tmp/ticgit/.git/remote: Counting objects: 591, done.remote: Compressing objects: 100% (267/267), done.remote: Total 591 (delta 253), reused 587 (delta 252)Receiving objects: 100% (591/591), 73.05 KiB, done.Resolving deltas: 100% (253/253), done.$ cd ticgit/$ ls.git LICENSE! ! Rakefile! examples! note! !ticgit.gemspec README!! bin!! lib!! spec$

Page 92: Git 101 tutorial presentation

A Basic Workflow

Page 93: Git 101 tutorial presentation

A Basic Workflow

Edit files

Stage the changes

Review your changes

Commit the changes

Page 94: Git 101 tutorial presentation

working directory

repository

index

git add

git commit

Page 95: Git 101 tutorial presentation

working directory

repository

index

git add

git commit

a working copy of your project

Page 96: Git 101 tutorial presentation

working directory

repository

index

git add

git commit

object database

Page 97: Git 101 tutorial presentation

working directory

repository

index

git add

git commit

“staging”

Page 98: Git 101 tutorial presentation

A Basic Workflow

Edit files

Stage the changes

Review your changes

Commit the changes

Page 99: Git 101 tutorial presentation

$ find ../app.yaml./index.yaml./main.py

Page 100: Git 101 tutorial presentation

#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hello world!')

def main(): application = webapp.WSGIApplication([('/', MainHandler)], debug=True) wsgiref.handlers.CGIHandler().run(application)

if __name__ == '__main__': main()~ ~ "main.py" 16L, 402C

$ vim main.py

Page 101: Git 101 tutorial presentation

#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

# this program prints out ‘hello world’

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hello world!')

def main(): application = webapp.WSGIApplication([('/', MainHandler)], debug=True) wsgiref.handlers.CGIHandler().run(application)

if __name__ == '__main__': main()~ ~ "main.py" 16L, 402C

$ vim main.py

Page 102: Git 101 tutorial presentation

$ git status

Page 103: Git 101 tutorial presentation

$ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)##modified: main.py#no changes added to commit (use "git add" and/or "git commit -a")

Page 104: Git 101 tutorial presentation

$ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)##modified: main.py#no changes added to commit (use "git add" and/or "git commit -a")

Page 105: Git 101 tutorial presentation

$ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)##modified: main.py#no changes added to commit (use "git add" and/or "git commit -a")

Page 106: Git 101 tutorial presentation

$ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)##modified: main.py#no changes added to commit (use "git add" and/or "git commit -a")

STAGED

Page 107: Git 101 tutorial presentation

A Basic Workflow

Edit files

Stage the changes

Review your changes

Commit the changes

Page 108: Git 101 tutorial presentation

git add

Page 109: Git 101 tutorial presentation

working directory

repository

index

git add

git commit

Page 110: Git 101 tutorial presentation

working directory

repository

index

git add

git commit

Page 111: Git 101 tutorial presentation

$ git add main.py$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)##modified: main.py#

Page 112: Git 101 tutorial presentation

# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)##modified: main.py#

$ git add main.py$ git status

Page 113: Git 101 tutorial presentation

# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)##modified: main.py#

$ git add main.py$ git status

THAT ARE STAGED

Page 114: Git 101 tutorial presentation

$ vim app.yamlapplication: chaconversion: 1runtime: pythonapi_version: 1

handlers:- url: .* script: main.py~ ~ ~ "app.yaml" 8L, 101C

Page 115: Git 101 tutorial presentation

application: chaconversion: 1runtime: pythonapi_version: 1

handlers:- url: .* script: main.py~ ~ ~ "app.yaml" 8L, 101C

$ vim app.yaml

Page 116: Git 101 tutorial presentation

application: chaconversion: 2runtime: pythonapi_version: 1

handlers:- url: .* script: main.py~ ~ ~ "app.yaml" 8L, 101C

$ vim app.yaml

Page 117: Git 101 tutorial presentation

$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: main.py## Changed but not updated:# (use "git add <file>..." to update what will be committed)## modified: app.yaml#

Page 118: Git 101 tutorial presentation

$ vim main.py#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

# this program prints out ‘hello world’

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hello world!')

def main(): application = webapp.WSGIApplication([('/', MainHandler)], debug=True) wsgiref.handlers.CGIHandler().run(application)

if __name__ == '__main__': main()~ ~ "main.py" 16L, 402C

Page 119: Git 101 tutorial presentation

#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

# this program prints out ‘hello world’

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hola world!')

def main(): application = webapp.WSGIApplication([('/', MainHandler)], debug=True) wsgiref.handlers.CGIHandler().run(application)

if __name__ == '__main__': main()~ ~ "main.py" 16L, 402C

$ vim main.py

Page 120: Git 101 tutorial presentation

#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

# this program prints out ‘hello world’

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hola Mundo!')

def main(): application = webapp.WSGIApplication([('/', MainHandler)], debug=True) wsgiref.handlers.CGIHandler().run(application)

if __name__ == '__main__': main()~ ~ "main.py" 16L, 402C

$ vim main.py

Page 121: Git 101 tutorial presentation

# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: main.py## Changed but not updated:# (use "git add <file>..." to update what will be committed)## modified: app.yaml# modified: main.py#

$ git status

Page 122: Git 101 tutorial presentation

# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: main.py## Changed but not updated:# (use "git add <file>..." to update what will be committed)## modified: app.yaml# modified: main.py#

$ git status

Staged

Page 123: Git 101 tutorial presentation

# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: main.py## Changed but not updated:# (use "git add <file>..." to update what will be committed)## modified: app.yaml# modified: main.py#

$ git status

Unstaged

Page 124: Git 101 tutorial presentation

# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: main.py## Changed but not updated:# (use "git add <file>..." to update what will be committed)## modified: app.yaml# modified: main.py#

$ git status

Page 125: Git 101 tutorial presentation

#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

# this program prints out ‘hello world’

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hola Mundo!')

def main(): application = webapp.WSGIApplication([('/' debug=True) wsgiref.handlers.CGIHandler().run(applicat

if __name__ == '__main__': main()

#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

# this program prints out ‘hello world’

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hello World!')

def main(): application = webapp.WSGIApplication([('/' debug=True) wsgiref.handlers.CGIHandler().run(applicat

if __name__ == '__main__': main()

Staged In Working Directory

Page 126: Git 101 tutorial presentation

#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

# this program prints out ‘hello world’

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hola Mundo!')

def main(): application = webapp.WSGIApplication([('/' debug=True) wsgiref.handlers.CGIHandler().run(applicat

if __name__ == '__main__': main()

#!/usr/bin/env pythonimport wsgiref.handlersfrom google.appengine.ext import webapp

# this program prints out ‘hello world’

class MainHandler(webapp.RequestHandler):

def get(self): self.response.out.write('Hello World!')

def main(): application = webapp.WSGIApplication([('/' debug=True) wsgiref.handlers.CGIHandler().run(applicat

if __name__ == '__main__': main()

Staged In Working Directory

Page 127: Git 101 tutorial presentation

You have to stage a file after you edit it

Page 128: Git 101 tutorial presentation

You have to stage a file after you edit it

Page 129: Git 101 tutorial presentation

You have to stage a file after you edit it

Page 130: Git 101 tutorial presentation

$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: app.yaml# modified: main.py#

$ git add app.yaml main.py

Page 131: Git 101 tutorial presentation

A Basic Workflow

Edit files

Stage the changes

Review your changes

Commit the changes

Page 132: Git 101 tutorial presentation

git commit

Page 133: Git 101 tutorial presentation

working directory

repository

index

git add

git commit

Page 134: Git 101 tutorial presentation

working directory

repository

index

git add

git commit

Page 135: Git 101 tutorial presentation

$ git commit

# Please enter the commit message for your changes. Lines starting# with '#' will be ignored, and an empty message aborts the commit.# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: app.yaml# modified: main.py#~ ~ ~ ~ ".git/COMMIT_EDITMSG" 10L, 279C

Page 136: Git 101 tutorial presentation

descriptive commit message# Please enter the commit message for your changes. Lines starting# with '#' will be ignored, and an empty message aborts the commit.# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: app.yaml# modified: main.py#~ ~ ~ ~ ".git/COMMIT_EDITMSG" 10L, 279C

$ git commit

Page 137: Git 101 tutorial presentation

descriptive commit message# Please enter the commit message for your changes. Lines starting# with '#' will be ignored, and an empty message aborts the commit.# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: app.yaml# modified: main.py#~ ~ ~ ~ ".git/COMMIT_EDITMSG" 10L, 279C

$ git commit

Page 138: Git 101 tutorial presentation

$ git commitCreated commit 77d3001: descriptive commit message 2 files changed, 4 insertions(+), 2 deletions(-)

Page 139: Git 101 tutorial presentation

A Basic Workflow

Edit files

Stage the changes

Review your changes

Commit the changes

vim / emacs / etc

git add (file)

repo status

git commit

Page 140: Git 101 tutorial presentation

A Basic Workflow

Edit files

Stage the changes

Review your changes

Commit the changes

vim / emacs / etc

git add (file)

repo status

git commit

Page 141: Git 101 tutorial presentation

A Basic Workflow

Edit files

Stage the changes

Review your changes

Commit the changes

vim / emacs / etc

git add (file)

repo status

git commit

Page 142: Git 101 tutorial presentation

A Basic Workflow

Edit files

Stage the changes

Review your changes

Commit the changes

vim / emacs / etc

git add (file)

git status

git commit

Page 143: Git 101 tutorial presentation

A Basic Workflow

Edit files

Stage the changes

Review your changes

Commit the changes

vim / emacs / etc

git add (file)

git status

git commit

Page 144: Git 101 tutorial presentation

A Basicer Workflow

Edit files

Stage and Commit

vim / emacs / etc

git commit -a

Page 145: Git 101 tutorial presentation

What’s going on here?

Page 146: Git 101 tutorial presentation

$ git commitCreated commit 77d3001: descriptive commit message 2 files changed, 4 insertions(+), 2 deletions(-)

Page 147: Git 101 tutorial presentation

$ git commitCreated commit 77d3001: descriptive commit message 2 files changed, 4 insertions(+), 2 deletions(-)

Page 148: Git 101 tutorial presentation

77d3001

Page 149: Git 101 tutorial presentation

77d3001a1de6bf8f5e431972fe4d25b01e595c0b

Page 150: Git 101 tutorial presentation

77d3001a1de6bf8f5e431972fe4d25b01e595c0b

Page 151: Git 101 tutorial presentation

77d3001a1de6bf8f5e431972fe4d25b01e595c0b

commit size

ae668..

tree

parent

author

committermy commit message goes hereand it is really, really cool

c4ec5

a149e

Scott

Scott

Page 152: Git 101 tutorial presentation

77d3001a1de6bf8f5e431972fe4d25b01e595c0b

commit size

ae668..

tree

parent

author

committermy commit message goes hereand it is really, really cool

c4ec5

a149e

Scott

Scott

tree c4ec543b0322744e55c5efc9b6c4e449d398dbffparent a149e2160b3f7573768cdc2fce24d0881f3577e1author Scott Chacon <[email protected]> 1223402504 -0700committer Scott Chacon <[email protected]> 1223402504 -0700

descriptive commit message

Page 153: Git 101 tutorial presentation

77d3001a1de6bf8f5e431972fe4d25b01e595c0b

commit size

ae668..

tree

parent

author

committermy commit message goes hereand it is really, really cool

c4ec5

a149e

Scott

Scott

Page 154: Git 101 tutorial presentation

77d3001a1de6bf8f5e431972fe4d25b01e595c0b

commit size

ae668..

tree

parent

author

committermy commit message goes hereand it is really, really cool

c4ec5

a149e

Scott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

Page 155: Git 101 tutorial presentation

commit size

ae668..

tree

parent

author

committermy commit message goes hereand it is really, really cool

c4ec5

a149e

Scott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

commit size

tree

parent

author

committerthis is the previous commitand I am very proud of it

2de54

38def

Scott

Scott

Page 156: Git 101 tutorial presentation

commit size

ae668..

tree

parent

author

committermy commit message goes hereand it is really, really cool

c4ec5

a149e

Scott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

commit size

tree

parent

author

committerthis is the previous commitand I am very proud of it

2de54

38def

Scott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

Page 157: Git 101 tutorial presentation

commit size

ae668..

tree

parent

author

committermy commit message goes hereand it is really, really cool

c4ec5

a149e

Scott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

commit size

tree

parent

author

committerthis is the previous commitand I am very proud of it

2de54

38def

Scott

Scott

commit size

tree

parent

author

committerthis is the commit before thatand I'm not sure why

2fe65

90ecd

Scott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

commit size

tree

parent

author

committerthis is the commit before thatand I'm not sure why

2fe65

90ecd

Scott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

Page 158: Git 101 tutorial presentation

commit size

ae668..

tree

parent

author

committermy commit message goes hereand it is really, really cool

c4ec5

a149e

Scott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

commit size

tree

parent

author

committerthis is the previous commitand I am very proud of it

2de54

38def

Scott

Scott

commit size

tree

parent

author

committerthis is the commit before thatand I'm not sure why

2fe65

90ecd

Scott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

commit size

tree

parent

author

committerthis is the commit before thatand I'm not sure why

2fe65

90ecd

Scott

Scott

app.yaml

index.yaml

main.py

./ c4e

03e

1d3

3d5

48e 77da1438d

c4e

3d5

1d3

03e

f46

23f

30e

67e

32a

5b1

Page 159: Git 101 tutorial presentation

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

Page 160: Git 101 tutorial presentation

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

git checkout ae635

Page 161: Git 101 tutorial presentation

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

git checkout ae635

Page 162: Git 101 tutorial presentation

Working DirectoryIndex

Rakefile

README

simplegit.rb

./

lib/

./Rakefile

./README

./lib/simplegit.rb

./

./lib/ c36

3d4

03e

5b1

1d3

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

Page 163: Git 101 tutorial presentation

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

Working DirectoryIndex

Rakefile

README

simplegit.rb

./

lib/

./Rakefile

./README

./lib/simplegit.rb

./

./lib/ c36

3d4

03e

5b1

1d3

Page 164: Git 101 tutorial presentation

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

Working DirectoryIndex

Rakefile

README

simplegit.rb

./

lib/

./Rakefile

./README

./lib/simplegit.rb

./

./lib/ c36

3d4

03e

5b1

1d3

Page 165: Git 101 tutorial presentation

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

Working DirectoryIndex

Rakefile

README

simplegit.rb

./

lib/

./Rakefile

./README

./lib/simplegit.rb

./

./lib/ c36

3d4

03e

5b1

1d3

Page 166: Git 101 tutorial presentation

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

Working DirectoryIndex

Rakefile

README

simplegit.rb

./

lib/

./Rakefile

./README

./lib/simplegit.rb

./

./lib/ c36

3d4

03e

5b1

1d3

git add

Page 167: Git 101 tutorial presentation

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

Working DirectoryIndex

Rakefile

README

simplegit.rb

./

lib/

./Rakefile

./README

./lib/simplegit.rb

./

./lib/ c36

3d4

03e

5b1

1d3

git add

34f

Page 168: Git 101 tutorial presentation

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

Working DirectoryIndex

Rakefile

README

simplegit.rb

./

lib/

./Rakefile

./README

./lib/simplegit.rb

./

./lib/ c36

3d4

03e

5b1

1d3

git commit

34f

a083da34f

ae9

Page 169: Git 101 tutorial presentation

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

Working DirectoryIndex

Rakefile

README

simplegit.rb

./

lib/

./Rakefile

./README

./lib/simplegit.rb

./

./lib/ c36

3d4

03e

5b1

1d334f

a083da34f

ae9

Page 170: Git 101 tutorial presentation

Repository

3d4

03e

ae6

5b1

1d3

c36

f46

23f

6fe

30e

67e

32a

ffe

38d

5b1

1d3

254

a14

d23

2d3

48e

735

de3

c4ec4e

77d

3d5

Working DirectoryIndex

Rakefile

README

simplegit.rb

./

lib/

./Rakefile

./README

./lib/simplegit.rb

./

./lib/ c36

3d4

03e

5b1

1d334f

a083da34f

ae9

Page 171: Git 101 tutorial presentation

object model

blob

commit

tree

C1}directory list

file contents

pointer to a snapshot

Page 172: Git 101 tutorial presentation

object model

blob

commit

tree

C1}directory list

file contents

pointer to a snapshot

Page 173: Git 101 tutorial presentation

ref

commit commitcommit

tree

treeblob

tree

treeblob

tree

treeblob

blob

Page 174: Git 101 tutorial presentation

Bulk Staging

Page 175: Git 101 tutorial presentation

working directory

repository

index

Page 176: Git 101 tutorial presentation

working directory

repository

index

git add

Page 177: Git 101 tutorial presentation

working directory

repository

index

git addgit add

git add

Page 178: Git 101 tutorial presentation

working directory

repository

index

git add

git commit

Page 179: Git 101 tutorial presentation

git add -u

Page 180: Git 101 tutorial presentation

git commit -a

Page 181: Git 101 tutorial presentation

working directory

repository

git commit -aindex

Page 182: Git 101 tutorial presentation

git commit -agit add -ugit commit

Page 183: Git 101 tutorial presentation

Patch Staging

Page 184: Git 101 tutorial presentation

git add -p

Page 185: Git 101 tutorial presentation

$ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)##modified: ticgit.gemspec#no changes added to commit (use "git add" and/or "git commit -a")

Page 186: Git 101 tutorial presentation

$ git status# On branch master# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)##modified: ticgit.gemspec#no changes added to commit (use "git add" and/or "git commit -a")

Page 187: Git 101 tutorial presentation

$ git add -pdiff --git a/ticgit.gemspec b/ticgit.gemspecindex 9c32bd4..a44667b 100644--- a/ticgit.gemspec+++ b/ticgit.gemspec@@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = "ticgit"- s.version = "0.3.5"+ s.version = "0.3.6" s.date = "2008-05-10" s.author = "Scott Chacon" s.email = "[email protected]"Stage this hunk [y,n,a,d,/,j,J,g,e,?]? y

Page 188: Git 101 tutorial presentation

$ git add -pdiff --git a/ticgit.gemspec b/ticgit.gemspecindex 9c32bd4..a44667b 100644--- a/ticgit.gemspec+++ b/ticgit.gemspec@@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = "ticgit"- s.version = "0.3.5"+ s.version = "0.3.6" s.date = "2008-05-10" s.author = "Scott Chacon" s.email = "[email protected]"Stage this hunk [y,n,a,d,/,j,J,g,e,?]? y

Page 189: Git 101 tutorial presentation

$ git add -pdiff --git a/ticgit.gemspec b/ticgit.gemspecindex 9c32bd4..a44667b 100644--- a/ticgit.gemspec+++ b/ticgit.gemspec@@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = "ticgit"- s.version = "0.3.5"+ s.version = "0.3.6" s.date = "2008-05-10" s.author = "Scott Chacon" s.email = "[email protected]"Stage this hunk [y,n,a,d,/,j,J,g,e,?]?

Page 190: Git 101 tutorial presentation

$ git add -pdiff --git a/ticgit.gemspec b/ticgit.gemspecindex 9c32bd4..a44667b 100644--- a/ticgit.gemspec+++ b/ticgit.gemspec@@ -1,7 +1,7 @@ Gem::Specification.new do |s| s.platform = Gem::Platform::RUBY s.name = "ticgit"- s.version = "0.3.5"+ s.version = "0.3.6" s.date = "2008-05-10" s.author = "Scott Chacon" s.email = "[email protected]"Stage this hunk [y,n,a,d,/,j,J,g,e,?]? y

Page 191: Git 101 tutorial presentation

@@ -9,9 +9,10 @@ Gem::Specification.new do |s| s.files = ["lib/ticgit/base.rb", "lib/ticgit/cli.rb", "lib/ticgit/comment.rb", "lib/ticgit/ticket.rb", "lib/ticgit.rb", "bin/ti", "bin/ticgitweb"] s.bindir = 'bin'- s.executables << "ti"- s.executables << "ticgitweb"+ s.executables = ["ti", "ticgitweb"]+ s.default_executable = %q{ti} s.homepage = "http://github/schacon/ticgit" s.require_paths = ["lib", "bin"]+ s.specification_version = 2 if s.respond_to? :specification_version= endStage this hunk [y,n,a,d,/,K,g,s,e,?]?

Page 192: Git 101 tutorial presentation

@@ -9,9 +9,10 @@ Gem::Specification.new do |s| s.files = ["lib/ticgit/base.rb", "lib/ticgit/cli.rb", "lib/ticgit/comment.rb", "lib/ticgit/ticket.rb", "lib/ticgit.rb", "bin/ti", "bin/ticgitweb"] s.bindir = 'bin'- s.executables << "ti"- s.executables << "ticgitweb"+ s.executables = ["ti", "ticgitweb"]+ s.default_executable = %q{ti} s.homepage = "http://github/schacon/ticgit" s.require_paths = ["lib", "bin"]+ s.specification_version = 2 if s.respond_to? :specification_version= endStage this hunk [y,n,a,d,/,K,g,s,e,?]?

Page 193: Git 101 tutorial presentation

@@ -9,9 +9,10 @@ Gem::Specification.new do |s| s.files = ["lib/ticgit/base.rb", "lib/ticgit/cli.rb", "lib/ticgit/comment.rb", "lib/ticgit/ticket.rb", "lib/ticgit.rb", "bin/ti", "bin/ticgitweb"] s.bindir = 'bin'- s.executables << "ti"- s.executables << "ticgitweb"+ s.executables = ["ti", "ticgitweb"]+ s.default_executable = %q{ti} s.homepage = "http://github/schacon/ticgit" s.require_paths = ["lib", "bin"]+ s.specification_version = 2 if s.respond_to? :specification_version= endStage this hunk [y,n,a,d,/,K,g,s,e,?]? n

Page 194: Git 101 tutorial presentation

$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: ticgit.gemspec## Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: ticgit.gemspec#

Page 195: Git 101 tutorial presentation

$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: ticgit.gemspec## Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: ticgit.gemspec#

Page 196: Git 101 tutorial presentation

$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: ticgit.gemspec## Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: ticgit.gemspec#

Page 197: Git 101 tutorial presentation

$ git status# On branch master# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: ticgit.gemspec## Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: ticgit.gemspec#

Page 198: Git 101 tutorial presentation

partially stage files

Page 199: Git 101 tutorial presentation

git add -p

Page 200: Git 101 tutorial presentation

Changes

Page 201: Git 101 tutorial presentation

deltastorage

snapshotstorage

Page 202: Git 101 tutorial presentation

deltastorage

snapshotstorage

Page 203: Git 101 tutorial presentation

deltastorage

snapshotstorage

Page 204: Git 101 tutorial presentation

git diff

Page 205: Git 101 tutorial presentation
Page 206: Git 101 tutorial presentation

What is not yet staged?

Page 207: Git 101 tutorial presentation

git diff

Page 208: Git 101 tutorial presentation

git diff

working directory

repository

index

Page 209: Git 101 tutorial presentation

What is staged?

Page 210: Git 101 tutorial presentation

git diff --cached

Page 211: Git 101 tutorial presentation

git diff --cached

working directory

repository

index

Page 212: Git 101 tutorial presentation

git diff --stat

Page 213: Git 101 tutorial presentation

$ git diff --stat kidgloves.rb | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)

Page 214: Git 101 tutorial presentation

Unified Diff

Page 215: Git 101 tutorial presentation

git diff > change.patch

Page 216: Git 101 tutorial presentation

git diff > change.patch

patch -p1 < change.patch

Page 217: Git 101 tutorial presentation

git diff > change.patch

patch -p1 < change.patch

git apply change.patchor

Page 218: Git 101 tutorial presentation

History

Page 219: Git 101 tutorial presentation

git log

Page 220: Git 101 tutorial presentation
Page 221: Git 101 tutorial presentation
Page 222: Git 101 tutorial presentation
Page 223: Git 101 tutorial presentation
Page 224: Git 101 tutorial presentation
Page 225: Git 101 tutorial presentation
Page 226: Git 101 tutorial presentation
Page 227: Git 101 tutorial presentation
Page 228: Git 101 tutorial presentation

Branching and Merging

Page 229: Git 101 tutorial presentation

branches

Page 230: Git 101 tutorial presentation

brancheslightweight, movablepointers to a commit

C1

branch

Page 231: Git 101 tutorial presentation

branching

Page 232: Git 101 tutorial presentation

git branch

Page 233: Git 101 tutorial presentation

git checkout

Page 234: Git 101 tutorial presentation

C1

master

C0

C2 C3

experiment

HEAD

default

Page 235: Git 101 tutorial presentation

C1

master

C0

C2 C3

experimentC1

master

C0

C2 C3

C4

experiment

C5

T1

git branch experiment

HEAD

default

Page 236: Git 101 tutorial presentation

C1

master

C0

C2 C3

experimentC1

master

C0

C2 C3

C4

experiment

C5

T1

git branch experiment

HEAD

default

Page 237: Git 101 tutorial presentation

C1

master

C0

C2 C3

experimentC1

master

C0

C2 C3

C4

experiment

C5

T1

HEAD

$ git branch* default experiment

default

Page 238: Git 101 tutorial presentation

C1

master

C0

C2 C3

experimentC1

master

C0

C2 C3

C4

experiment

C5

T1

HEAD

$ git branch* default experiment

default

Page 239: Git 101 tutorial presentation

C1

master

C0

C2 C3

experimentC1

master

C0

C2 C3

C4

experiment

C5

T1

git checkout experiment

HEAD

default

Page 240: Git 101 tutorial presentation

C1

master

C0

C2 C3

experiment

C1

master

C0

C2 C3

C4

experiment

C5

T1

git commit

HEAD

default

Page 241: Git 101 tutorial presentation

C1

master

C0

C2 C3

experiment

C1

master

C0

C2 C3

C4

experiment

C5

T1

git commit

HEAD

default

Page 242: Git 101 tutorial presentation

C1

master

C0

C2 C3

experiment

C1

master

C0

C2 C3

C4

experiment

C5

T1

git commit

HEAD

default

Page 243: Git 101 tutorial presentation

C1

master

C0

C2 C3

experiment

C1

master

C0

C2 C3

C4

experiment

C5

T1

git commitgit commit

HEAD

default

Page 244: Git 101 tutorial presentation

C1

master

C0

C2 C3

experiment

C1

master

C0

C2 C3

C4

experiment

C5

T1

HEAD

git checkout defaultdefault

Page 245: Git 101 tutorial presentation

C1

master

C0

C2 C3

experiment

C1

master

C0

C2 C3

C4

experiment

C5

T1

HEAD

git checkout defaultdefault

Page 246: Git 101 tutorial presentation

C1

master

C0

C2 C3

C4

experiment

C5

T1

C1

master

C0

C2 C3

C4

experiment

C5

T1git commit

HEAD

default

Page 247: Git 101 tutorial presentation

C1

master

C0

C2 C3

C4

experiment

C5

T1

C1

master

C0

C2 C3

C4

experiment

C5

T1git commit

HEAD

default

Page 248: Git 101 tutorial presentation

C1

master

C0

C2 C3

C4

experiment

C5

T1

C1

master

C0

C2 C3

C4

experiment

C5

T1git commit

HEAD

default

Page 249: Git 101 tutorial presentation

C1

master

C0

C2 C3

C4

experiment

C5

T1

git checkout experimentgit commit

HEAD

default

Page 250: Git 101 tutorial presentation

what is a branch, really?

Page 251: Git 101 tutorial presentation

$ find .git/refs.git/refs.git/refs/heads.git/refs/heads/default.git/refs/heads/experiment

Page 252: Git 101 tutorial presentation

$ find .git/refs.git/refs.git/refs/heads.git/refs/heads/default.git/refs/heads/experiment

Page 253: Git 101 tutorial presentation

$ find .git/refs.git/refs.git/refs/heads.git/refs/heads/default.git/refs/heads/experiment

Page 254: Git 101 tutorial presentation

$ find .git/refs.git/refs.git/refs/heads.git/refs/heads/default.git/refs/heads/experiment

$ cat .git/refs/heads/default6370409dc9e38af91565082bdf93577ff555489e

Page 255: Git 101 tutorial presentation

$ find .git/refs.git/refs.git/refs/heads.git/refs/heads/default.git/refs/heads/experiment

$ cat .git/refs/heads/default6370409dc9e38af91565082bdf93577ff555489e$ cat .git/refs/heads/experiment 33ce13c2f0ed35775956f81191b01a644448dcfc

Page 256: Git 101 tutorial presentation

$ cat .git/HEAD ref: refs/heads/experiment

Page 257: Git 101 tutorial presentation

$ cat .git/HEAD ref: refs/heads/experiment

Page 258: Git 101 tutorial presentation

$ cat .git/HEAD ref: refs/heads/experiment

Page 259: Git 101 tutorial presentation

merging

Page 260: Git 101 tutorial presentation

git merge

Page 261: Git 101 tutorial presentation

C1

master

C0

C2 C3

C4

experiment

C5

T1

HEAD

default

Page 262: Git 101 tutorial presentation

C1

master

C0

C2 C3

C4

experiment

C5

T1

HEAD

git checkout default

default

Page 263: Git 101 tutorial presentation

C1C0

C2 C3

C4

experiment

C5

C6

masterT1

git checkout defaultgit merge experiment

HEAD

default

Page 264: Git 101 tutorial presentation

C1C0

C2 C3

C4

experiment

C5

C6

masterT1

git checkout defaultgit merge experiment

HEAD

default

Page 265: Git 101 tutorial presentation

C1C0

C2 C3

C4

C5

C6

C7

C8

default

experiment

HEADgit checkout experiment

Page 266: Git 101 tutorial presentation

C1C0

C2 C3

C4

C5

C6

C7

C8

default

experiment

HEADgit commit

Page 267: Git 101 tutorial presentation

C1C0

C2 C3

C4

C5

C6

C7

C8

default

experiment

HEAD

git checkout default

Page 268: Git 101 tutorial presentation

C1C0

C2 C3

C4

C5

C6

C7

C8

default

experiment

HEAD

git merge experiment

Page 269: Git 101 tutorial presentation

Why is this cool?

Page 270: Git 101 tutorial presentation

try out an idea

Page 271: Git 101 tutorial presentation

isolate work units

Page 272: Git 101 tutorial presentation

long running topics

Page 273: Git 101 tutorial presentation

visualizing your branches

Page 274: Git 101 tutorial presentation

git log --graph

Page 275: Git 101 tutorial presentation

git log --oneline --graph

Page 276: Git 101 tutorial presentation

gitk

Page 277: Git 101 tutorial presentation

gitk 6d13f..41aba

Page 278: Git 101 tutorial presentation

git log --all

Page 279: Git 101 tutorial presentation

Deleting Branches

Page 280: Git 101 tutorial presentation

git branch -d branch

Page 281: Git 101 tutorial presentation

git branch -D branch

Page 282: Git 101 tutorial presentation

Stashing

Page 283: Git 101 tutorial presentation

when a commit is too much

Page 284: Git 101 tutorial presentation

$ git status# On branch iss53# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/alarmclock/AlarmAlert.java# modified: src/com/android/alarmclock/AlarmAlertWakeLock.java#no changes added to commit (use "git add" and/or "git commit -a")

$ git stashSaved working directory and index state "WIP on iss53: c8208f9... Merge branch 'cupcake'"HEAD is now at c8208f9 Merge branch 'cupcake'(To restore them type "git stash apply")

$ git status# On branch iss53nothing to commit (working directory clean)

Page 285: Git 101 tutorial presentation

$ git status# On branch iss53# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/alarmclock/AlarmAlert.java# modified: src/com/android/alarmclock/AlarmAlertWakeLock.java#no changes added to commit (use "git add" and/or "git commit -a")

$ git stashSaved working directory and index state "WIP on iss53: c8208f9... Merge branch 'cupcake'"HEAD is now at c8208f9 Merge branch 'cupcake'(To restore them type "git stash apply")

$ git status# On branch iss53nothing to commit (working directory clean)

Page 286: Git 101 tutorial presentation

$ git status# On branch iss53# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/alarmclock/AlarmAlert.java# modified: src/com/android/alarmclock/AlarmAlertWakeLock.java#no changes added to commit (use "git add" and/or "git commit -a")

$ git stashSaved working directory and index state "WIP on iss53: c8208f9... Merge branch 'cupcake'"HEAD is now at c8208f9 Merge branch 'cupcake'(To restore them type "git stash apply")

$ git status# On branch iss53nothing to commit (working directory clean)

Page 287: Git 101 tutorial presentation

$ git status# On branch iss53# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/alarmclock/AlarmAlert.java# modified: src/com/android/alarmclock/AlarmAlertWakeLock.java#no changes added to commit (use "git add" and/or "git commit -a")

$ git stashSaved working directory and index state "WIP on iss53: c8208f9... Merge branch 'cupcake'"HEAD is now at c8208f9 Merge branch 'cupcake'(To restore them type "git stash apply")

$ git status# On branch iss53nothing to commit (working directory clean)

Page 288: Git 101 tutorial presentation

$ git status# On branch iss53# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/alarmclock/AlarmAlert.java# modified: src/com/android/alarmclock/AlarmAlertWakeLock.java#no changes added to commit (use "git add" and/or "git commit -a")

$ git stashSaved working directory and index state "WIP on iss53: c8208f9... Merge branch 'cupcake'"HEAD is now at c8208f9 Merge branch 'cupcake'(To restore them type "git stash apply")

$ git status# On branch iss53nothing to commit (working directory clean)

Page 289: Git 101 tutorial presentation

$ git status# On branch iss53# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/alarmclock/AlarmAlert.java# modified: src/com/android/alarmclock/AlarmAlertWakeLock.java#no changes added to commit (use "git add" and/or "git commit -a")

$ git stashSaved working directory and index state "WIP on iss53: c8208f9... Merge branch 'cupcake'"HEAD is now at c8208f9 Merge branch 'cupcake'(To restore them type "git stash apply")

$ git status# On branch iss53nothing to commit (working directory clean)

Page 290: Git 101 tutorial presentation

$ git status# On branch iss53# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/alarmclock/AlarmAlert.java# modified: src/com/android/alarmclock/AlarmAlertWakeLock.java#no changes added to commit (use "git add" and/or "git commit -a")

$ git stashSaved working directory and index state "WIP on iss53: c8208f9... Merge branch 'cupcake'"HEAD is now at c8208f9 Merge branch 'cupcake'(To restore them type "git stash apply")

$ git status# On branch iss53nothing to commit (working directory clean)

Page 291: Git 101 tutorial presentation

$ git status# On branch iss53# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/alarmclock/AlarmAlert.java# modified: src/com/android/alarmclock/AlarmAlertWakeLock.java#no changes added to commit (use "git add" and/or "git commit -a")

$ git stashSaved working directory and index state "WIP on iss53: c8208f9... Merge branch 'cupcake'"HEAD is now at c8208f9 Merge branch 'cupcake'(To restore them type "git stash apply")

$ git status# On branch iss53nothing to commit (working directory clean)

Page 292: Git 101 tutorial presentation

$ git status# On branch iss53# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/alarmclock/AlarmAlert.java# modified: src/com/android/alarmclock/AlarmAlertWakeLock.java#no changes added to commit (use "git add" and/or "git commit -a")

$ git stashSaved working directory and index state "WIP on iss53: c8208f9... Merge branch 'cupcake'"HEAD is now at c8208f9 Merge branch 'cupcake'(To restore them type "git stash apply")

$ git status# On branch iss53nothing to commit (working directory clean)

Page 293: Git 101 tutorial presentation

$ git stash liststash@{0}: WIP on iss53: c8208f9... Merge branch 'cupcake'

$ git stash apply# On branch iss53# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/alarmclock/AlarmAlert.java# modified: src/com/android/alarmclock/AlarmAlertWakeLock.java#no changes added to commit (use "git add" and/or "git commit -a")

$ git stash liststash@{0}: WIP on iss53: c8208f9... Merge branch 'cupcake'

$ git stash drop stash@{0}Dropped stash@{0} (e19b0e94032d0614f450238f91953fe5e7e454a8)

Page 294: Git 101 tutorial presentation

$ git stash liststash@{0}: WIP on iss53: c8208f9... Merge branch 'cupcake'

$ git stash apply# On branch iss53# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/alarmclock/AlarmAlert.java# modified: src/com/android/alarmclock/AlarmAlertWakeLock.java#no changes added to commit (use "git add" and/or "git commit -a")

$ git stash liststash@{0}: WIP on iss53: c8208f9... Merge branch 'cupcake'

$ git stash drop stash@{0}Dropped stash@{0} (e19b0e94032d0614f450238f91953fe5e7e454a8)

Page 295: Git 101 tutorial presentation

$ git stash liststash@{0}: WIP on iss53: c8208f9... Merge branch 'cupcake'

$ git stash apply# On branch iss53# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/alarmclock/AlarmAlert.java# modified: src/com/android/alarmclock/AlarmAlertWakeLock.java#no changes added to commit (use "git add" and/or "git commit -a")

$ git stash liststash@{0}: WIP on iss53: c8208f9... Merge branch 'cupcake'

$ git stash drop stash@{0}Dropped stash@{0} (e19b0e94032d0614f450238f91953fe5e7e454a8)

Page 296: Git 101 tutorial presentation

$ git stash liststash@{0}: WIP on iss53: c8208f9... Merge branch 'cupcake'

$ git stash apply# On branch iss53# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/alarmclock/AlarmAlert.java# modified: src/com/android/alarmclock/AlarmAlertWakeLock.java#no changes added to commit (use "git add" and/or "git commit -a")

$ git stash liststash@{0}: WIP on iss53: c8208f9... Merge branch 'cupcake'

$ git stash drop stash@{0}Dropped stash@{0} (e19b0e94032d0614f450238f91953fe5e7e454a8)

Page 297: Git 101 tutorial presentation

$ git stash liststash@{0}: WIP on iss53: c8208f9... Merge branch 'cupcake'

$ git stash apply# On branch iss53# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/alarmclock/AlarmAlert.java# modified: src/com/android/alarmclock/AlarmAlertWakeLock.java#no changes added to commit (use "git add" and/or "git commit -a")

$ git stash liststash@{0}: WIP on iss53: c8208f9... Merge branch 'cupcake'

$ git stash drop stash@{0}Dropped stash@{0} (e19b0e94032d0614f450238f91953fe5e7e454a8)

Page 298: Git 101 tutorial presentation

$ git stash liststash@{0}: WIP on iss53: c8208f9... Merge branch 'cupcake'

$ git stash apply# On branch iss53# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/alarmclock/AlarmAlert.java# modified: src/com/android/alarmclock/AlarmAlertWakeLock.java#no changes added to commit (use "git add" and/or "git commit -a")

$ git stash liststash@{0}: WIP on iss53: c8208f9... Merge branch 'cupcake'

$ git stash drop stash@{0}Dropped stash@{0} (e19b0e94032d0614f450238f91953fe5e7e454a8)

Page 299: Git 101 tutorial presentation

$ git stash liststash@{0}: WIP on iss53: c8208f9... Merge branch 'cupcake'

$ git stash apply# On branch iss53# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/alarmclock/AlarmAlert.java# modified: src/com/android/alarmclock/AlarmAlertWakeLock.java#no changes added to commit (use "git add" and/or "git commit -a")

$ git stash liststash@{0}: WIP on iss53: c8208f9... Merge branch 'cupcake'

$ git stash drop stash@{0}Dropped stash@{0} (e19b0e94032d0614f450238f91953fe5e7e454a8)

Page 300: Git 101 tutorial presentation

$ git stash liststash@{0}: WIP on iss53: c8208f9... Merge branch 'cupcake'

$ git stash apply# On branch iss53# Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/alarmclock/AlarmAlert.java# modified: src/com/android/alarmclock/AlarmAlertWakeLock.java#no changes added to commit (use "git add" and/or "git commit -a")

$ git stash liststash@{0}: WIP on iss53: c8208f9... Merge branch 'cupcake'

$ git stash drop stash@{0}Dropped stash@{0} (e19b0e94032d0614f450238f91953fe5e7e454a8)

Page 301: Git 101 tutorial presentation

git stash branch new_branch stash@{1}

Page 302: Git 101 tutorial presentation

git stashsave

list

drop

pop

apply

branch

Page 303: Git 101 tutorial presentation

Remotes

Page 304: Git 101 tutorial presentation

sharing git

Page 305: Git 101 tutorial presentation
Page 306: Git 101 tutorial presentation
Page 307: Git 101 tutorial presentation
Page 308: Git 101 tutorial presentation
Page 309: Git 101 tutorial presentation
Page 310: Git 101 tutorial presentation
Page 311: Git 101 tutorial presentation
Page 312: Git 101 tutorial presentation
Page 313: Git 101 tutorial presentation
Page 314: Git 101 tutorial presentation
Page 315: Git 101 tutorial presentation
Page 316: Git 101 tutorial presentation
Page 317: Git 101 tutorial presentation
Page 318: Git 101 tutorial presentation
Page 319: Git 101 tutorial presentation
Page 320: Git 101 tutorial presentation
Page 321: Git 101 tutorial presentation
Page 322: Git 101 tutorial presentation

git clone git://github.com/schacon/simplegit2.git

Page 323: Git 101 tutorial presentation

distributed workflow

Page 324: Git 101 tutorial presentation

distributed workflowfetch, pull and push

Page 325: Git 101 tutorial presentation

fetch

Page 326: Git 101 tutorial presentation
Page 327: Git 101 tutorial presentation
Page 328: Git 101 tutorial presentation
Page 329: Git 101 tutorial presentation
Page 330: Git 101 tutorial presentation
Page 331: Git 101 tutorial presentation
Page 332: Git 101 tutorial presentation

pull

Page 333: Git 101 tutorial presentation

pull = fetch + merge

Page 334: Git 101 tutorial presentation

push

Page 335: Git 101 tutorial presentation
Page 336: Git 101 tutorial presentation
Page 337: Git 101 tutorial presentation
Page 338: Git 101 tutorial presentation

git push

Page 339: Git 101 tutorial presentation
Page 340: Git 101 tutorial presentation

git push origin branchA:branchB

Page 341: Git 101 tutorial presentation

a who in the what now?

Page 342: Git 101 tutorial presentation

public repo

local repo

local repo

public repo

internet

A B C

Page 343: Git 101 tutorial presentation

public repo

local repo

local repo

public repo

git push(ssh)

internet

A B C

A B C

Page 344: Git 101 tutorial presentation

public repo

local repo

local repo

public repo

git push(ssh)

git fetch(git)

internet

A B C

A B C

A B C

Page 345: Git 101 tutorial presentation

public repo

local repo

local repo

public repo

git push(ssh)

git fetch(git)

internet

A B C

A B C

A B C

D E F git commit

Page 346: Git 101 tutorial presentation

public repo

local repo

local repo

public repo

git push(ssh)

git fetch(git)

git push(ssh)

internet

A B C

A B C

A B C

D E F

A B C

D E F

Page 347: Git 101 tutorial presentation

public repo

local repo

local repo

public repo

git fetch(http)

git push(ssh)

git fetch(git)

git push(ssh)

internet

A B C

A B C

A B C

D E F

A B C

D E F

D E F

Page 348: Git 101 tutorial presentation

public repo

local repo

local repo

public repo

git fetch(http)

git push(ssh)

git fetch(git)

git push(ssh)

internet

A B C

A B C

A B C

D E F

A B C

D E F

D E FD E F

Page 349: Git 101 tutorial presentation

multiple remotes

Page 350: Git 101 tutorial presentation

developernick

developerjessica

my repo5ec

e4a4a7ce0 master

Page 351: Git 101 tutorial presentation

developernick

developerjessica

my repo5ec

e4a4a7ce0 master

commit

Page 352: Git 101 tutorial presentation

developernick

developerjessica

my repo5ec

e4a4a7ce0 master

tree

Page 353: Git 101 tutorial presentation

developernick

developerjessica

my repo5ec

e4a4a7ce0 master

blobs

Page 354: Git 101 tutorial presentation

schacon/project

developernick

developerjessica

"public"

my repo5ec

e4a4a7ce0 master

git push public

public/master

5ece4a

4a7ce0

Page 355: Git 101 tutorial presentation

schacon/project

developerjessica

"public"

my repo5ec

e4a4a7ce0 master

git clone (url)

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nick

Page 356: Git 101 tutorial presentation

schacon/project

developerjessica

"public"

my repo5ec

e4a4a7ce0 master

git commit

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

Page 357: Git 101 tutorial presentation

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f git clone (url)

5ece4a

4a7ce0developer

jessica

Page 358: Git 101 tutorial presentation

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09git commit

Page 359: Git 101 tutorial presentation

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09git push

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09

Page 360: Git 101 tutorial presentation

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git remote add nick git://github.com/nickh/project.git

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick"

git remote add nick git://github.com/nickh/project.git

Page 361: Git 101 tutorial presentation

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git remote add nick git://github.com/nickh/project.git

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick"“nick”

git remote add nick git://github.com/nickh/project.git

Page 362: Git 101 tutorial presentation

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git remote add jess git://github.com/jessica/project.git

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

git remote add jess git://github.com/jessica/project.git

Page 363: Git 101 tutorial presentation

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git remote add jess git://github.com/jessica/project.git

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

git remote add jess git://github.com/jessica/project.git

“jess”

Page 364: Git 101 tutorial presentation

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git remote add jess git://github.com/jessica/project.git

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git fetch nick

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

c12ec524f nick/master

git fetch nick

Page 365: Git 101 tutorial presentation

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git fetch nick

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

c12ec524f nick/master

Page 366: Git 101 tutorial presentation

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git remote add jess git://github.com/jessica/project.git

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

git fetch jess

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git fetch jess

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

ec524f nick/master

2fbdf74eaa09

jess/masterc12

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git fetch nick

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

c12ec524f nick/master

Page 367: Git 101 tutorial presentation

schacon/project

"public"

my repo5ec

e4a4a7ce0 master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git fetch jess

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

ec524f nick/master

2fbdf74eaa09

jess/masterc12

Page 368: Git 101 tutorial presentation

schacon/project

"public"

my repo5ec

e4a4a7ce0

master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

ec524f nick/master

2fbdf74eaa09

jess/masterc12

b3bc63

git merge nick jessgit merge nick/master jess/master

Page 369: Git 101 tutorial presentation

schacon/project

"public"

my repo5ec

e4a4a7ce0

master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

git push public

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

ec524f nick/master

2fbdf74eaa09

jess/masterc12

b3bc63

e4aec524f

2fbdf74eaa09

c12

b3bc63

Page 370: Git 101 tutorial presentation

schacon/project

"public"

my repo5ec

e4a4a7ce0

master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

ec524f nick/master

2fbdf74eaa09

jess/masterc12

b3bc63

e4aec524f

2fbdf74eaa09

c12

b3bc63

Page 371: Git 101 tutorial presentation

schacon/project

"public"

my repo5ec

e4a4a7ce0

master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

ec524f nick/master

2fbdf74eaa09

jess/masterc12

b3bc63

e4aec524f

2fbdf74eaa09

c12

b3bc63

Page 372: Git 101 tutorial presentation

schacon/project

"public"

my repo5ec

e4a4a7ce0

master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

ec524f nick/master

2fbdf74eaa09

jess/masterc12

b3bc63

e4aec524f

2fbdf74eaa09

c12

b3bc63

Page 373: Git 101 tutorial presentation

schacon/project

"public"

my repo5ec

e4a4a7ce0

master

public/master

5ece4a

4a7ce0

5ece4a

4a7ce0developer

nickc12ec524f

5ece4a

4a7ce0developer

jessica2fbdf74ea

a09

5ece4a

4a7ce0nickh/project

c12ec524f

5ece4a

4a7ce0jessica/project

2fbdf74eaa09"nick" "jess"

ec524f nick/master

2fbdf74eaa09

jess/masterc12

b3bc63

e4aec524f

2fbdf74eaa09

c12

b3bc63

Page 374: Git 101 tutorial presentation

Remotes Are Branches

Page 375: Git 101 tutorial presentation

C0

default

scott jessica

C1

Page 376: Git 101 tutorial presentation

C0

default

scott jessica

C1

C0

scott/default default

C1

Page 377: Git 101 tutorial presentation

C0

default

scott jessica

C1

C0

scott/default default

C1

git clone

Page 378: Git 101 tutorial presentation

C0

default

scott jessica

C1

C0

scott/default default

C1

Page 379: Git 101 tutorial presentation

C0

default

scott jessica

C1

C0

scott/default default

C1

Page 380: Git 101 tutorial presentation

C0

default

scott jessica

C1 C1

C0

scott/default

default

C2

C3

C4

Page 381: Git 101 tutorial presentation

C0

default

scott jessica

C1 C1

C0

scott/default

default

C2

C3

C4

Page 382: Git 101 tutorial presentation

C0

default

scott jessica

C1 C1

C0

scott/default

default

C2

C3

C4

Page 383: Git 101 tutorial presentation

C0

default

scott

C1

C5

C6

C7

jessica

C1

C0

scott/default

default

C2

C3

C4

Page 384: Git 101 tutorial presentation

C0

default

scott

C1

C5

C6

C7

jessica

C1

C0

scott/default

default

C2

C3

C4

Page 385: Git 101 tutorial presentation

C0

default

scott jessica

C1

C0

scott/default default

C2

C3

C4

C1

C5

C6

C7

C5

C6

C7

Page 386: Git 101 tutorial presentation

C0

default

scott jessica

C1

C0

scott/default default

C2

C3

C4

C1

C5

C6

C7

C5

C6

C7

experiment

C8

C9

Page 387: Git 101 tutorial presentation

C0

default

scott jessica

C1

C0

scott/default default

C2

C3

C4

C1

C5

C6

C7

C5

C6

C7

experiment

C8

C9

Page 388: Git 101 tutorial presentation

C0

default

scott jessica

C1

C0

scott/default default

C2

C3

C4

C1

C5

C6

C7

C5

C6

C7

experiment

C8

C9

git merge experiment

git merge scott/default

Page 389: Git 101 tutorial presentation

C0

default

scott jessica

C1

C0

scott/default default

C2

C3

C4

C1

C5

C6

C7

C5

C6

C7

experiment

C8

C9

Page 390: Git 101 tutorial presentation

C0

default

scott jessica

C1

C0

scott/default default

C2

C3

C4

C1

C5

C6

C7

C5

C6

C7

experiment

C8

C9

a “remote” branch is simply alocal pointer to the last known

state of another repository

Page 391: Git 101 tutorial presentation

Tagging

Page 392: Git 101 tutorial presentation

lightweight tags

Page 393: Git 101 tutorial presentation

Snapshot A Snapshot B Snapshot C

98ca9 34ac2 f30ab

master

HEAD

Page 394: Git 101 tutorial presentation

git tag v1.0

Page 395: Git 101 tutorial presentation

Snapshot A Snapshot B Snapshot C

98ca9 34ac2 f30ab

master

HEAD

v1.0

Page 396: Git 101 tutorial presentation

Snapshot A Snapshot B Snapshot C

98ca9 34ac2 f30ab

master

HEAD

v1.0

Snapshot D

a38d3

Page 397: Git 101 tutorial presentation

annotated tags

Page 398: Git 101 tutorial presentation

git tag -a v1.1 34ac2

Page 399: Git 101 tutorial presentation

tag size

49e11..

object

type

tagger

my tag message that explains

this tag

ae668

commit

Scott

tag v1.3

Page 400: Git 101 tutorial presentation

Snapshot A Snapshot B Snapshot C

98ca9 34ac2 f30ab

master

HEAD

v1.0

Snapshot D

a38d3

tag data

v1.1

Page 401: Git 101 tutorial presentation

tagging objects

Page 402: Git 101 tutorial presentation

git hash-object -w file.txt

Page 403: Git 101 tutorial presentation

$ git hash-object -w ~/README.txt 35a0dd3af166e09ac378dfeb95953923e71ea45b

$ git tag -a my_readme 35a0dd3af166e09ac378dfeb95953923e71ea45b

$ git show my_readmetag my_readmeTagger: Scott Chacon <[email protected]>Date: Tue Mar 16 08:36:24 2010 -0700

my readmeMy README File by Scott Chacon

This is my READMEThere are many like itBut this one is mine

Page 404: Git 101 tutorial presentation

$ git hash-object -w ~/README.txt 35a0dd3af166e09ac378dfeb95953923e71ea45b

$ git tag -a my_readme 35a0dd3af166e09ac378dfeb95953923e71ea45b

$ git show my_readmetag my_readmeTagger: Scott Chacon <[email protected]>Date: Tue Mar 16 08:36:24 2010 -0700

my readmeMy README File by Scott Chacon

This is my READMEThere are many like itBut this one is mine

Page 405: Git 101 tutorial presentation

$ git hash-object -w ~/README.txt 35a0dd3af166e09ac378dfeb95953923e71ea45b

$ git tag -a my_readme 35a0dd3af166e09ac378dfeb95953923e71ea45b

$ git show my_readmetag my_readmeTagger: Scott Chacon <[email protected]>Date: Tue Mar 16 08:36:24 2010 -0700

my readmeMy README File by Scott Chacon

This is my READMEThere are many like itBut this one is mine

Page 406: Git 101 tutorial presentation

sharing tags

Page 407: Git 101 tutorial presentation

git push --tags

Page 408: Git 101 tutorial presentation

Git Inspection

Page 409: Git 101 tutorial presentation

Revision Selection

Page 410: Git 101 tutorial presentation

Revision Selection

alternate ways to refer to objects or ranges of objects

Page 411: Git 101 tutorial presentation

Revision Selectionfull sha-1

partial sha-1

branch or tag name

caret parent

tilde spec

blob spec

relative specs

ranges

Page 412: Git 101 tutorial presentation

Full SHA1

6e453f523fa1da50ecb04431101112b3611c6a4d

Page 413: Git 101 tutorial presentation

Partial SHA16e453f523fa1da50ecb04431101112b3611c6a4d

6e453f523fa1da50

6e453

Page 414: Git 101 tutorial presentation

Branch, Remote or Tag Name

v1.0

default

m/cupcake

Page 415: Git 101 tutorial presentation

Caret Parent

default^2

2nd parent of ‘default’

Page 416: Git 101 tutorial presentation

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

Page 417: Git 101 tutorial presentation

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

master^

Page 418: Git 101 tutorial presentation

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

master^2

Page 419: Git 101 tutorial presentation

Tilde Spec

default~2

grandparent of ‘default’(parent of the parent)

Page 420: Git 101 tutorial presentation

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

master~2

Page 421: Git 101 tutorial presentation

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

master^^^2master~2^2

Page 422: Git 101 tutorial presentation

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

master^^^2master~2^2

Page 423: Git 101 tutorial presentation

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

master^^^2master~2^2

Page 424: Git 101 tutorial presentation

Blob Spec

default:path/to/file

blob of that file in ‘default’ commit

Page 425: Git 101 tutorial presentation

Relative Specs

master@{yesterday}

the commit ‘master’ was at yesterday

Page 426: Git 101 tutorial presentation

Relative Specs

master@{5}

the 5th prior value of ‘master’ (locally)

Page 427: Git 101 tutorial presentation

Ranges

ce0e4..e4272

every commit reachable by e4272 that is not reachable by ce034

Page 428: Git 101 tutorial presentation

Ranges

[old]..[new]

every commit reachable by [new] that is not reachable by [old]

Page 429: Git 101 tutorial presentation

Ranges

ce0e4..

everything since a commit

Page 430: Git 101 tutorial presentation

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master..master

Page 431: Git 101 tutorial presentation

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master..master

Page 432: Git 101 tutorial presentation

jess/master..master

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

Page 433: Git 101 tutorial presentation

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master..master

Page 434: Git 101 tutorial presentation

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master..c36ae

Page 435: Git 101 tutorial presentation

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master..c36ae

Page 436: Git 101 tutorial presentation

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master..c36ae

Page 437: Git 101 tutorial presentation

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master..c36ae

Page 438: Git 101 tutorial presentation

Ranges

ce0e4...e4272

every commit reachable by eitherbut not commits reachable by both

Page 439: Git 101 tutorial presentation

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master...c36ae

Page 440: Git 101 tutorial presentation

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master...c36ae

Page 441: Git 101 tutorial presentation

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master...c36ae

Page 442: Git 101 tutorial presentation

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master...c36ae

Page 443: Git 101 tutorial presentation

Advanced Log

Page 444: Git 101 tutorial presentation

Log Subsets

Page 445: Git 101 tutorial presentation

git log m/cupcake..

Page 446: Git 101 tutorial presentation

C1

C0

m/cupcake default HEAD

Page 447: Git 101 tutorial presentation

C1

C0

C2

C3

default C4

m/cupcake

HEAD

Page 448: Git 101 tutorial presentation

C1

C0

C2

C3

default C4

m/cupcake

HEAD

git log m/cupcake..

Page 449: Git 101 tutorial presentation

C1

C0

C2

C3

default C4

m/cupcake

HEAD

git log m/cupcake..HEAD

Page 450: Git 101 tutorial presentation

C1

C0

C2

C3

default C4

m/cupcake

HEAD

git log m/cupcake..HEAD

Page 451: Git 101 tutorial presentation

C1

C0

C2

C3

default C4

m/cupcake

HEAD

git log m/cupcake..HEAD

Page 452: Git 101 tutorial presentation

C1

C0

C2

C3

default C4

m/cupcake

HEAD

git log m/cupcake..HEAD

Page 453: Git 101 tutorial presentation

commit 72d404debaa804fca82fd9cf710fbde48c7305c6Author: Shawn O. Pearce <[email protected]>Date: Sun Oct 12 13:13:59 2008 -0700

test-lib: fix broken printf b8eecafd888d219633f4c29e8b6a90fc21a46dfd introduced usage of printf without a format string. Signed-off-by: Shawn O. Pearce <[email protected]>

commit 969c877506cf8cc760c7b251fef6c5b6850bfc19Author: Jeff King <[email protected]>Date: Sun Oct 12 00:06:11 2008 -0400

git apply --directory broken for new files We carefully verify that the input to git-apply is sane, including cross-checking that the filenames we see in "+++" headers match what was provided on the command line of "diff --git". When --directory is used, however, we ended up comparing the unadorned name to one with the prepended root, causing us to complain about a mismatch. We simply need to prepend the root directory, if any, when pulling the name out of the git header. commit ff74126c03a8dfd04e7533573a5c420f2a7112acAuthor: Johannes Schindelin <[email protected]>Date: Fri Oct 10 13:42:12 2008 +0200

rebase -i: do not fail when there is no commit to cherry-pick

Page 454: Git 101 tutorial presentation

commit 72d404debaa804fca82fd9cf710fbde48c7305c6Author: Shawn O. Pearce <[email protected]>Date: Sun Oct 12 13:13:59 2008 -0700

test-lib: fix broken printf b8eecafd888d219633f4c29e8b6a90fc21a46dfd introduced usage of printf without a format string. Signed-off-by: Shawn O. Pearce <[email protected]>

commit 969c877506cf8cc760c7b251fef6c5b6850bfc19Author: Jeff King <[email protected]>Date: Sun Oct 12 00:06:11 2008 -0400

git apply --directory broken for new files We carefully verify that the input to git-apply is sane, including cross-checking that the filenames we see in "+++" headers match what was provided on the command line of "diff --git". When --directory is used, however, we ended up comparing the unadorned name to one with the prepended root, causing us to complain about a mismatch. We simply need to prepend the root directory, if any, when pulling the name out of the git header. commit ff74126c03a8dfd04e7533573a5c420f2a7112acAuthor: Johannes Schindelin <[email protected]>Date: Fri Oct 10 13:42:12 2008 +0200

rebase -i: do not fail when there is no commit to cherry-pick

C2

C3

C4

Page 455: Git 101 tutorial presentation

git log m/cupcake..

git log m/cupcake..HEAD

git log HEAD ^m/cupcake

git log 35ae2 ^9fe42

Page 456: Git 101 tutorial presentation

git log 3e45a ^573eb

Page 457: Git 101 tutorial presentation

git log 3e45a ^573eb

Page 458: Git 101 tutorial presentation

git log 08cb1 ca374 ^c0bf9

Page 459: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

m/cupcake

git log c5 c7 ^c9

Page 460: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

m/cupcakem/cupcake

default

git log c5 c7 ^c9

Page 461: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

m/cupcakem/cupcake

default

git log c5 c7 ^c9

Page 462: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

m/cupcakem/cupcake

git log c5 c7 ^c9

Page 463: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

git log c5 c7 ^c9

Page 464: Git 101 tutorial presentation

which changes aren’t in experiment?

Page 465: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

git log m/cupcake default ^experiment

Page 466: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

git log m/cupcake default ^experiment

Page 467: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

git log m/cupcake default ^experiment

Page 468: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

git log m/cupcake default ^experiment

Page 469: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

git log m/cupcake default ^experiment

Page 470: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

git log m/cupcake default ^experiment

Page 471: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

git log m/cupcake default ^experiment

Page 472: Git 101 tutorial presentation

Log Formatting

Page 473: Git 101 tutorial presentation

git log -p

Page 474: Git 101 tutorial presentation
Page 475: Git 101 tutorial presentation
Page 476: Git 101 tutorial presentation
Page 477: Git 101 tutorial presentation
Page 478: Git 101 tutorial presentation
Page 479: Git 101 tutorial presentation

git log -p

Page 480: Git 101 tutorial presentation

git log --pretty

Page 481: Git 101 tutorial presentation
Page 482: Git 101 tutorial presentation
Page 483: Git 101 tutorial presentation
Page 484: Git 101 tutorial presentation
Page 485: Git 101 tutorial presentation
Page 486: Git 101 tutorial presentation
Page 487: Git 101 tutorial presentation

git log --left-right

Page 488: Git 101 tutorial presentation

$ git log --pretty=oneline --left-right 5f7f801...77976b<5f7f801227868c7abcce7e58dee3eff855011955 convert file browser to html>77976b24ff839c59c3b20d80cb28351ccb5e59a8 remove cruft>09b76d2966e2370a78ed37a31c2f7c23d08609c3 git-log>7000b24511618a21d40b39ee213d397e1d29497d like i said>c2a6adfcd18c0d95dbed6ea62ac9c9a912d18123 create this on deploy>6ba3609953d5c46a76ca1d0d3d83018be61454e6 i am too meta for you<3dff6074fe205e36fae219f277ef87aab097e236 Merge branch 'master' into html<1cdc8437fa6c621d96c4dfa5f6370c8fdb9cbc3d Merge branch 'master' into html<20125a6d37d5c1614ffe1de94ca064095968e7f0 delete default images

Page 489: Git 101 tutorial presentation

$ git log --pretty=oneline --left-right 5f7f801...77976b<5f7f801227868c7abcce7e58dee3eff855011955 convert file browser to html>77976b24ff839c59c3b20d80cb28351ccb5e59a8 remove cruft>09b76d2966e2370a78ed37a31c2f7c23d08609c3 git-log>7000b24511618a21d40b39ee213d397e1d29497d like i said>c2a6adfcd18c0d95dbed6ea62ac9c9a912d18123 create this on deploy>6ba3609953d5c46a76ca1d0d3d83018be61454e6 i am too meta for you<3dff6074fe205e36fae219f277ef87aab097e236 Merge branch 'master' into html<1cdc8437fa6c621d96c4dfa5f6370c8fdb9cbc3d Merge branch 'master' into html<20125a6d37d5c1614ffe1de94ca064095968e7f0 delete default images

Page 490: Git 101 tutorial presentation

$ git log --pretty=oneline --left-right 5f7f801...77976b<5f7f801227868c7abcce7e58dee3eff855011955 convert file browser to html>77976b24ff839c59c3b20d80cb28351ccb5e59a8 remove cruft>09b76d2966e2370a78ed37a31c2f7c23d08609c3 git-log>7000b24511618a21d40b39ee213d397e1d29497d like i said>c2a6adfcd18c0d95dbed6ea62ac9c9a912d18123 create this on deploy>6ba3609953d5c46a76ca1d0d3d83018be61454e6 i am too meta for you<3dff6074fe205e36fae219f277ef87aab097e236 Merge branch 'master' into html<1cdc8437fa6c621d96c4dfa5f6370c8fdb9cbc3d Merge branch 'master' into html<20125a6d37d5c1614ffe1de94ca064095968e7f0 delete default images

Page 491: Git 101 tutorial presentation

$ git log --pretty=oneline --left-right 5f7f801...77976b<5f7f801227868c7abcce7e58dee3eff855011955 convert file browser to html>77976b24ff839c59c3b20d80cb28351ccb5e59a8 remove cruft>09b76d2966e2370a78ed37a31c2f7c23d08609c3 git-log>7000b24511618a21d40b39ee213d397e1d29497d like i said>c2a6adfcd18c0d95dbed6ea62ac9c9a912d18123 create this on deploy>6ba3609953d5c46a76ca1d0d3d83018be61454e6 i am too meta for you<3dff6074fe205e36fae219f277ef87aab097e236 Merge branch 'master' into html<1cdc8437fa6c621d96c4dfa5f6370c8fdb9cbc3d Merge branch 'master' into html<20125a6d37d5c1614ffe1de94ca064095968e7f0 delete default images

Page 492: Git 101 tutorial presentation

git log --graph

Page 493: Git 101 tutorial presentation

git log --pretty=oneline --graph

Page 494: Git 101 tutorial presentation

gitk

Page 495: Git 101 tutorial presentation

gitk 6d13f..41aba

Page 496: Git 101 tutorial presentation

Merged Branches

Page 497: Git 101 tutorial presentation

git branch --merged

Page 498: Git 101 tutorial presentation

git branch --no-merged

Page 499: Git 101 tutorial presentation

Branch Diffs

Page 500: Git 101 tutorial presentation

git diff branch

Page 501: Git 101 tutorial presentation

diff --git a/Rakefile b/Rakefileindex eb54561..2d2c777 100644--- a/Rakefile+++ b/Rakefile@@ -17,10 +17,6 @@ Rake::GemPackageTask.new(spec) do |pkg| pkg.need_tar = true end -task :default => "pkg/#{spec.name}-#{spec.version}.gem" do- puts "generated latest version"-end- desc "Regenerate Documentation" task :doc do |t| system('rdoc lib/ README --main README --inline-source')diff --git a/TODO b/TODOdeleted file mode 100644index bbe7708..0000000--- a/TODO+++ /dev/null@@ -1,7 +0,0 @@-Git Functions:-* add

Page 502: Git 101 tutorial presentation

git diff --stat

Page 503: Git 101 tutorial presentation

$ git diff --stat branch1 Rakefile | 4 ---- TODO | 7 ------- lib/simple_git.rb | 48 ------------------------------------------------ lib/simplegit.rb | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 52 insertions(+), 59 deletions(-)

Page 504: Git 101 tutorial presentation

git diff --name-only

Page 505: Git 101 tutorial presentation

$ git diff --name-only branchRakefileTODOlib/simple_git.rblib/simplegit.rb

Page 506: Git 101 tutorial presentation

git diff branch

Page 507: Git 101 tutorial presentation

git diff branch HEAD

Page 508: Git 101 tutorial presentation

git diff branch1 branch2

Page 509: Git 101 tutorial presentation

Revision Diffs

Page 510: Git 101 tutorial presentation

git diff revA revB

Page 511: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

Page 512: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

git diff c6 c4

Page 513: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

git diff c6 c4

Page 514: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

git diff c6 c4

Page 515: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

git diff c6 c4this may not be what you want!

Page 516: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

./file1C1

Page 517: Git 101 tutorial presentation

C2

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

./file1C1

./file1

./file2

Page 518: Git 101 tutorial presentation

C2

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

./file1C1

./file1

./file2C3 ./file1

./file3

Page 519: Git 101 tutorial presentation

C2

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

./file1C1

./file1

./file2C3 ./file1

./file3

C4 ./file1./file3./file4

Page 520: Git 101 tutorial presentation

C2

C1

C0

C2

C6

C7

C3

C4

C8

C9

C5

m/cupcake default

experiment

./file1C1

./file1

./file2C3 ./file1

./file3

C4 ./file1./file3./file4

C6 ./file1./file2./file6

Page 521: Git 101 tutorial presentation

C2

./file1C1

./file1

./file2C3 ./file1

./file3

C4 ./file1./file3./file4

C6 ./file1./file2./file6

git diff c6 c4

+file3+file4

Page 522: Git 101 tutorial presentation

C2

./file1C1

./file1

./file2C3 ./file1

./file3

C4 ./file1./file3./file4

C6 ./file1./file2./file6

git diff c6 c4

+file3+file4

Page 523: Git 101 tutorial presentation

C2

./file1C1

./file1

./file2C3 ./file1

./file3

C4 ./file1./file3./file4

C6 ./file1./file2./file6

git diff c6 c4

+file3+file4-file2-file6

Page 524: Git 101 tutorial presentation

C2

./file1C1

./file1

./file2C3 ./file1

./file3

C4 ./file1./file3./file4

C6 ./file1./file2./file6

git diff c6 c4

+file3+file4-file2-file6

Page 525: Git 101 tutorial presentation

C2

./file1C1

./file1

./file2C3 ./file1

./file3

C4 ./file1./file3./file4

C6 ./file1./file2./file6

git diff c6 c4

+file3+file4-file2-file6

Page 526: Git 101 tutorial presentation

C2

./file1C1

./file1

./file2C3 ./file1

./file3

C4 ./file1./file3./file4

C6 ./file1./file2./file6

git diff c1 c4

+file3+file4

Page 527: Git 101 tutorial presentation

C2

./file1

./file1

./file2C3 ./file1

./file3

C4./file1./file2./file6

git diff c6...c4

+file3+file4

./file1

./file3

./file4

C6

C1

Page 528: Git 101 tutorial presentation

Undo

Page 529: Git 101 tutorial presentation

Single File

Page 530: Git 101 tutorial presentation

git checkout [commit] file

Page 531: Git 101 tutorial presentation

$ git checkout master@{yesterday} netcfg.c

Page 532: Git 101 tutorial presentation

$ git checkout v1.0 netcfg.c

Page 533: Git 101 tutorial presentation

Entire Project

Page 534: Git 101 tutorial presentation

git reset

Page 535: Git 101 tutorial presentation

$ git status# Not currently on any branch.# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: src/com/android/launcher/Workspace.java## Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/launcher/LiveFolder.java#

Page 536: Git 101 tutorial presentation

$ git status# Not currently on any branch.# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: src/com/android/launcher/Workspace.java## Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/launcher/LiveFolder.java#

Page 537: Git 101 tutorial presentation

$ git status# Not currently on any branch.# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: src/com/android/launcher/Workspace.java## Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/launcher/LiveFolder.java#

Page 538: Git 101 tutorial presentation

$ git status# Not currently on any branch.# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: src/com/android/launcher/Workspace.java## Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/launcher/LiveFolder.java#

Page 539: Git 101 tutorial presentation

by default, reset changes the staging area

Page 540: Git 101 tutorial presentation

$ git status# Not currently on any branch.# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: src/com/android/launcher/Workspace.java## Changed but not updated:# (use "git add <file>..." to update what will be committed)# (use "git checkout -- <file>..." to discard changes in working directory)## modified: src/com/android/launcher/LiveFolder.java#

Page 541: Git 101 tutorial presentation

$ git reset --hard

Page 542: Git 101 tutorial presentation

--hard changes stage and working directory

Page 543: Git 101 tutorial presentation

you’ve made commits, but want to move them

to a topic branch

Page 544: Git 101 tutorial presentation

$ git branch experiment $ git reset --hard origin/master$ git checkout topicname

Page 545: Git 101 tutorial presentation

$ git branch experiment $ git reset --hard origin/master$ git checkout topicname

Page 546: Git 101 tutorial presentation

$ git branch experiment $ git reset --hard origin/master$ git checkout experiment

Page 547: Git 101 tutorial presentation

C0

HEAD

C1origin/master

master

Page 548: Git 101 tutorial presentation

C0

HEAD

C1origin/master

master

C2

C3

Page 549: Git 101 tutorial presentation

C0

HEAD

C1origin/master

master

C2

C3 experiment

git checkout experiment

Page 550: Git 101 tutorial presentation

C0

HEAD

C1origin/master

master C2

C3 experiment

git reset --hard origin/master

Page 551: Git 101 tutorial presentation

C0

HEAD

C1origin/master

master C2

C3

experiment

C4

git commit

Page 552: Git 101 tutorial presentation

Debugging

Page 553: Git 101 tutorial presentation

Annotation

Page 554: Git 101 tutorial presentation

git blame

Page 555: Git 101 tutorial presentation

git blameie: “what dumbass did this? oh, it was me...”

Page 556: Git 101 tutorial presentation

git blame daemon.c979e32fa (Randal L. Schwartz 2005-10-25 16:29:09 -0700 1) #include "cache.h"85023577 (Junio C Hamano 2006-12-19 14:34:12 -0800 2) #include "pkt-line.h"77cb17e9 (Michal Ostrowski 2006-01-10 21:12:17 -0500 3) #include "exec_cmd.h"49ba83fb (Jon Loeliger 2006-09-19 20:31:51 -0500 4) #include "interpolate.h"f8ff0c06 (Petr Baudis 2005-09-22 11:25:28 +0200 5) 85023577 (Junio C Hamano 2006-12-19 14:34:12 -0800 6) #include <syslog.h>85023577 (Junio C Hamano 2006-12-19 14:34:12 -0800 7) 695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 8) #ifndef HOST_NAME_MAX695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 9) #define HOST_NAME_MAX 256695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 10) #endif695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 11) 415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 12) #ifndef NI_MAXSERV415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 13) #define NI_MAXSERV 32415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 14) #endif415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 15) 9048fe1c (Petr Baudis 2005-09-24 16:13:01 +0200 16) static int log_syslog;f8ff0c06 (Petr Baudis 2005-09-22 11:25:28 +0200 17) static int verbose;1955fabf (Mark Wooding 2006-02-03 20:27:04 +0000 18) static int reuseaddr;f8ff0c06 (Petr Baudis 2005-09-22 11:25:28 +0200 19) 960deccb (H. Peter Anvin 2005-10-19 14:27:01 -0700 20) static const char daemon_usage[] =1b1dd23f (Stephan Beyer 2008-07-13 15:36:15 +0200 21) "git daemon [--verbose] [--syslog] [3bd62c21 (Stephen R. van den Berg 2008-08-14 20:02:20 +0200 22) " [--timeout=n] [--init-ti3bd62c21 (Stephen R. van den Berg 2008-08-14 20:02:20 +0200 23) " [--strict-paths] [--base73a7a656 (Jens Axboe 2007-07-27 14:00:29 -0700 24) " [--user-path | --user-pa49ba83fb (Jon Loeliger 2006-09-19 20:31:51 -0500 25) " [--interpolated-path=pat678dac6b (Tilman Sauerbeck 2006-08-22 19:37:41 +0200 26) " [--reuseaddr] [--detach]d9edcbd6 (Junio C Hamano 2006-09-07 01:40:04 -0700 27) " [--[enable|disable|allowdd467629 (Jon Loeliger 2006-09-26 09:47:43 -0500 28) " [--inetd | [--listen=hosdd467629 (Jon Loeliger 2006-09-26 09:47:43 -0500 29) " [--user=user dd467629 (Jon Loeliger 2006-09-26 09:47:43 -0500 30) " [directory...]";4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 31) 4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 32) /* List of acceptable pathname prefi96f1e58f (David Rientjes 2006-08-15 10:23:48 -0700 33) static char **ok_paths;96f1e58f (David Rientjes 2006-08-15 10:23:48 -0700 34) static int strict_paths;4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 35) 4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 36) /* If this is set, git-daemon-export96f1e58f (David Rientjes 2006-08-15 10:23:48 -0700 37) static int export_all_trees;

Page 557: Git 101 tutorial presentation

git blame daemon.c979e32fa (Randal L. Schwartz 2005-10-25 16:29:09 -0700 1) #include "cache.h"85023577 (Junio C Hamano 2006-12-19 14:34:12 -0800 2) #include "pkt-line.h"77cb17e9 (Michal Ostrowski 2006-01-10 21:12:17 -0500 3) #include "exec_cmd.h"49ba83fb (Jon Loeliger 2006-09-19 20:31:51 -0500 4) #include "interpolate.h"f8ff0c06 (Petr Baudis 2005-09-22 11:25:28 +0200 5) 85023577 (Junio C Hamano 2006-12-19 14:34:12 -0800 6) #include <syslog.h>85023577 (Junio C Hamano 2006-12-19 14:34:12 -0800 7) 695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 8) #ifndef HOST_NAME_MAX695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 9) #define HOST_NAME_MAX 256695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 10) #endif695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 11) 415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 12) #ifndef NI_MAXSERV415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 13) #define NI_MAXSERV 32415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 14) #endif415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 15) 9048fe1c (Petr Baudis 2005-09-24 16:13:01 +0200 16) static int log_syslog;f8ff0c06 (Petr Baudis 2005-09-22 11:25:28 +0200 17) static int verbose;1955fabf (Mark Wooding 2006-02-03 20:27:04 +0000 18) static int reuseaddr;f8ff0c06 (Petr Baudis 2005-09-22 11:25:28 +0200 19) 960deccb (H. Peter Anvin 2005-10-19 14:27:01 -0700 20) static const char daemon_usage[] =1b1dd23f (Stephan Beyer 2008-07-13 15:36:15 +0200 21) "git daemon [--verbose] [--syslog] [3bd62c21 (Stephen R. van den Berg 2008-08-14 20:02:20 +0200 22) " [--timeout=n] [--init-ti3bd62c21 (Stephen R. van den Berg 2008-08-14 20:02:20 +0200 23) " [--strict-paths] [--base73a7a656 (Jens Axboe 2007-07-27 14:00:29 -0700 24) " [--user-path | --user-pa49ba83fb (Jon Loeliger 2006-09-19 20:31:51 -0500 25) " [--interpolated-path=pat678dac6b (Tilman Sauerbeck 2006-08-22 19:37:41 +0200 26) " [--reuseaddr] [--detach]d9edcbd6 (Junio C Hamano 2006-09-07 01:40:04 -0700 27) " [--[enable|disable|allowdd467629 (Jon Loeliger 2006-09-26 09:47:43 -0500 28) " [--inetd | [--listen=hosdd467629 (Jon Loeliger 2006-09-26 09:47:43 -0500 29) " [--user=user dd467629 (Jon Loeliger 2006-09-26 09:47:43 -0500 30) " [directory...]";4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 31) 4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 32) /* List of acceptable pathname prefi96f1e58f (David Rientjes 2006-08-15 10:23:48 -0700 33) static char **ok_paths;96f1e58f (David Rientjes 2006-08-15 10:23:48 -0700 34) static int strict_paths;4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 35) 4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 36) /* If this is set, git-daemon-export96f1e58f (David Rientjes 2006-08-15 10:23:48 -0700 37) static int export_all_trees;

Page 558: Git 101 tutorial presentation

git blame daemon.c979e32fa (Randal L. Schwartz 2005-10-25 16:29:09 -0700 1) #include "cache.h"85023577 (Junio C Hamano 2006-12-19 14:34:12 -0800 2) #include "pkt-line.h"77cb17e9 (Michal Ostrowski 2006-01-10 21:12:17 -0500 3) #include "exec_cmd.h"49ba83fb (Jon Loeliger 2006-09-19 20:31:51 -0500 4) #include "interpolate.h"f8ff0c06 (Petr Baudis 2005-09-22 11:25:28 +0200 5) 85023577 (Junio C Hamano 2006-12-19 14:34:12 -0800 6) #include <syslog.h>85023577 (Junio C Hamano 2006-12-19 14:34:12 -0800 7) 695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 8) #ifndef HOST_NAME_MAX695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 9) #define HOST_NAME_MAX 256695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 10) #endif695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 11) 415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 12) #ifndef NI_MAXSERV415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 13) #define NI_MAXSERV 32415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 14) #endif415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 15) 9048fe1c (Petr Baudis 2005-09-24 16:13:01 +0200 16) static int log_syslog;f8ff0c06 (Petr Baudis 2005-09-22 11:25:28 +0200 17) static int verbose;1955fabf (Mark Wooding 2006-02-03 20:27:04 +0000 18) static int reuseaddr;f8ff0c06 (Petr Baudis 2005-09-22 11:25:28 +0200 19) 960deccb (H. Peter Anvin 2005-10-19 14:27:01 -0700 20) static const char daemon_usage[] =1b1dd23f (Stephan Beyer 2008-07-13 15:36:15 +0200 21) "git daemon [--verbose] [--syslog] [3bd62c21 (Stephen R. van den Berg 2008-08-14 20:02:20 +0200 22) " [--timeout=n] [--init-ti3bd62c21 (Stephen R. van den Berg 2008-08-14 20:02:20 +0200 23) " [--strict-paths] [--base73a7a656 (Jens Axboe 2007-07-27 14:00:29 -0700 24) " [--user-path | --user-pa49ba83fb (Jon Loeliger 2006-09-19 20:31:51 -0500 25) " [--interpolated-path=pat678dac6b (Tilman Sauerbeck 2006-08-22 19:37:41 +0200 26) " [--reuseaddr] [--detach]d9edcbd6 (Junio C Hamano 2006-09-07 01:40:04 -0700 27) " [--[enable|disable|allowdd467629 (Jon Loeliger 2006-09-26 09:47:43 -0500 28) " [--inetd | [--listen=hosdd467629 (Jon Loeliger 2006-09-26 09:47:43 -0500 29) " [--user=user dd467629 (Jon Loeliger 2006-09-26 09:47:43 -0500 30) " [directory...]";4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 31) 4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 32) /* List of acceptable pathname prefi96f1e58f (David Rientjes 2006-08-15 10:23:48 -0700 33) static char **ok_paths;96f1e58f (David Rientjes 2006-08-15 10:23:48 -0700 34) static int strict_paths;4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 35) 4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 36) /* If this is set, git-daemon-export96f1e58f (David Rientjes 2006-08-15 10:23:48 -0700 37) static int export_all_trees;

Page 559: Git 101 tutorial presentation

979e32fa (Randal L. Schwartz 2005-10-25 16:29:09 -0700 1) #include "cache.h"85023577 (Junio C Hamano 2006-12-19 14:34:12 -0800 2) #include "pkt-line.h"77cb17e9 (Michal Ostrowski 2006-01-10 21:12:17 -0500 3) #include "exec_cmd.h"49ba83fb (Jon Loeliger 2006-09-19 20:31:51 -0500 4) #include "interpolate.h"f8ff0c06 (Petr Baudis 2005-09-22 11:25:28 +0200 5) 85023577 (Junio C Hamano 2006-12-19 14:34:12 -0800 6) #include <syslog.h>85023577 (Junio C Hamano 2006-12-19 14:34:12 -0800 7) 695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 8) #ifndef HOST_NAME_MAX695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 9) #define HOST_NAME_MAX 256695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 10) #endif695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 11) 415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 12) #ifndef NI_MAXSERV415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 13) #define NI_MAXSERV 32415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 14) #endif415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 15) 9048fe1c (Petr Baudis 2005-09-24 16:13:01 +0200 16) static int log_syslog;f8ff0c06 (Petr Baudis 2005-09-22 11:25:28 +0200 17) static int verbose;1955fabf (Mark Wooding 2006-02-03 20:27:04 +0000 18) static int reuseaddr;f8ff0c06 (Petr Baudis 2005-09-22 11:25:28 +0200 19) 960deccb (H. Peter Anvin 2005-10-19 14:27:01 -0700 20) static const char daemon_usage[] =1b1dd23f (Stephan Beyer 2008-07-13 15:36:15 +0200 21) "git daemon [--verbose] [--syslog] [3bd62c21 (Stephen R. van den Berg 2008-08-14 20:02:20 +0200 22) " [--timeout=n] [--init-ti3bd62c21 (Stephen R. van den Berg 2008-08-14 20:02:20 +0200 23) " [--strict-paths] [--base73a7a656 (Jens Axboe 2007-07-27 14:00:29 -0700 24) " [--user-path | --user-pa49ba83fb (Jon Loeliger 2006-09-19 20:31:51 -0500 25) " [--interpolated-path=pat678dac6b (Tilman Sauerbeck 2006-08-22 19:37:41 +0200 26) " [--reuseaddr] [--detach]d9edcbd6 (Junio C Hamano 2006-09-07 01:40:04 -0700 27) " [--[enable|disable|allowdd467629 (Jon Loeliger 2006-09-26 09:47:43 -0500 28) " [--inetd | [--listen=hosdd467629 (Jon Loeliger 2006-09-26 09:47:43 -0500 29) " [--user=user dd467629 (Jon Loeliger 2006-09-26 09:47:43 -0500 30) " [directory...]";4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 31) 4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 32) /* List of acceptable pathname prefi96f1e58f (David Rientjes 2006-08-15 10:23:48 -0700 33) static char **ok_paths;96f1e58f (David Rientjes 2006-08-15 10:23:48 -0700 34) static int strict_paths;4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 35) 4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 36) /* If this is set, git-daemon-export96f1e58f (David Rientjes 2006-08-15 10:23:48 -0700 37) static int export_all_trees;

git blame daemon.c

Page 560: Git 101 tutorial presentation

979e32fa (Randal L. Schwartz 2005-10-25 16:29:09 -0700 1) #include "cache.h"85023577 (Junio C Hamano 2006-12-19 14:34:12 -0800 2) #include "pkt-line.h"77cb17e9 (Michal Ostrowski 2006-01-10 21:12:17 -0500 3) #include "exec_cmd.h"49ba83fb (Jon Loeliger 2006-09-19 20:31:51 -0500 4) #include "interpolate.h"f8ff0c06 (Petr Baudis 2005-09-22 11:25:28 +0200 5) 85023577 (Junio C Hamano 2006-12-19 14:34:12 -0800 6) #include <syslog.h>85023577 (Junio C Hamano 2006-12-19 14:34:12 -0800 7) 695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 8) #ifndef HOST_NAME_MAX695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 9) #define HOST_NAME_MAX 256695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 10) #endif695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 11) 415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 12) #ifndef NI_MAXSERV415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 13) #define NI_MAXSERV 32415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 14) #endif415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 15) 9048fe1c (Petr Baudis 2005-09-24 16:13:01 +0200 16) static int log_syslog;f8ff0c06 (Petr Baudis 2005-09-22 11:25:28 +0200 17) static int verbose;1955fabf (Mark Wooding 2006-02-03 20:27:04 +0000 18) static int reuseaddr;f8ff0c06 (Petr Baudis 2005-09-22 11:25:28 +0200 19) 960deccb (H. Peter Anvin 2005-10-19 14:27:01 -0700 20) static const char daemon_usage[] =1b1dd23f (Stephan Beyer 2008-07-13 15:36:15 +0200 21) "git daemon [--verbose] [--syslog] [3bd62c21 (Stephen R. van den Berg 2008-08-14 20:02:20 +0200 22) " [--timeout=n] [--init-ti3bd62c21 (Stephen R. van den Berg 2008-08-14 20:02:20 +0200 23) " [--strict-paths] [--base73a7a656 (Jens Axboe 2007-07-27 14:00:29 -0700 24) " [--user-path | --user-pa49ba83fb (Jon Loeliger 2006-09-19 20:31:51 -0500 25) " [--interpolated-path=pat678dac6b (Tilman Sauerbeck 2006-08-22 19:37:41 +0200 26) " [--reuseaddr] [--detach]d9edcbd6 (Junio C Hamano 2006-09-07 01:40:04 -0700 27) " [--[enable|disable|allowdd467629 (Jon Loeliger 2006-09-26 09:47:43 -0500 28) " [--inetd | [--listen=hosdd467629 (Jon Loeliger 2006-09-26 09:47:43 -0500 29) " [--user=user dd467629 (Jon Loeliger 2006-09-26 09:47:43 -0500 30) " [directory...]";4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 31) 4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 32) /* List of acceptable pathname prefi96f1e58f (David Rientjes 2006-08-15 10:23:48 -0700 33) static char **ok_paths;96f1e58f (David Rientjes 2006-08-15 10:23:48 -0700 34) static int strict_paths;4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 35) 4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 36) /* If this is set, git-daemon-export96f1e58f (David Rientjes 2006-08-15 10:23:48 -0700 37) static int export_all_trees;

git blame daemon.c

Page 561: Git 101 tutorial presentation

979e32fa (Randal L. Schwartz 2005-10-25 16:29:09 -0700 1) #include "cache.h"85023577 (Junio C Hamano 2006-12-19 14:34:12 -0800 2) #include "pkt-line.h"77cb17e9 (Michal Ostrowski 2006-01-10 21:12:17 -0500 3) #include "exec_cmd.h"49ba83fb (Jon Loeliger 2006-09-19 20:31:51 -0500 4) #include "interpolate.h"f8ff0c06 (Petr Baudis 2005-09-22 11:25:28 +0200 5) 85023577 (Junio C Hamano 2006-12-19 14:34:12 -0800 6) #include <syslog.h>85023577 (Junio C Hamano 2006-12-19 14:34:12 -0800 7) 695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 8) #ifndef HOST_NAME_MAX695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 9) #define HOST_NAME_MAX 256695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 10) #endif695dffe2 (Johannes Schindelin 2006-09-28 12:00:35 +0200 11) 415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 12) #ifndef NI_MAXSERV415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 13) #define NI_MAXSERV 32415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 14) #endif415e7b87 (Patrick Welche 2007-10-18 18:17:39 +0100 15) 9048fe1c (Petr Baudis 2005-09-24 16:13:01 +0200 16) static int log_syslog;f8ff0c06 (Petr Baudis 2005-09-22 11:25:28 +0200 17) static int verbose;1955fabf (Mark Wooding 2006-02-03 20:27:04 +0000 18) static int reuseaddr;f8ff0c06 (Petr Baudis 2005-09-22 11:25:28 +0200 19) 960deccb (H. Peter Anvin 2005-10-19 14:27:01 -0700 20) static const char daemon_usage[] =1b1dd23f (Stephan Beyer 2008-07-13 15:36:15 +0200 21) "git daemon [--verbose] [--syslog] [3bd62c21 (Stephen R. van den Berg 2008-08-14 20:02:20 +0200 22) " [--timeout=n] [--init-ti3bd62c21 (Stephen R. van den Berg 2008-08-14 20:02:20 +0200 23) " [--strict-paths] [--base73a7a656 (Jens Axboe 2007-07-27 14:00:29 -0700 24) " [--user-path | --user-pa49ba83fb (Jon Loeliger 2006-09-19 20:31:51 -0500 25) " [--interpolated-path=pat678dac6b (Tilman Sauerbeck 2006-08-22 19:37:41 +0200 26) " [--reuseaddr] [--detach]d9edcbd6 (Junio C Hamano 2006-09-07 01:40:04 -0700 27) " [--[enable|disable|allowdd467629 (Jon Loeliger 2006-09-26 09:47:43 -0500 28) " [--inetd | [--listen=hosdd467629 (Jon Loeliger 2006-09-26 09:47:43 -0500 29) " [--user=user dd467629 (Jon Loeliger 2006-09-26 09:47:43 -0500 30) " [directory...]";4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 31) 4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 32) /* List of acceptable pathname prefi96f1e58f (David Rientjes 2006-08-15 10:23:48 -0700 33) static char **ok_paths;96f1e58f (David Rientjes 2006-08-15 10:23:48 -0700 34) static int strict_paths;4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 35) 4ae95682 (H. Peter Anvin 2005-09-26 19:10:55 -0700 36) /* If this is set, git-daemon-export96f1e58f (David Rientjes 2006-08-15 10:23:48 -0700 37) static int export_all_trees;

git blame daemon.c

Page 562: Git 101 tutorial presentation

git blame -C GITPackUpload.m

Page 563: Git 101 tutorial presentation

git blame -C GITPackUpload.mf344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 12) f344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 13) #define PACK_SIGNf344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 14) #define PACK_VERSf344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 15) ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 16) @implementation Gad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 17) ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 18) @synthesize gitRead11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 19) @synthesize needRad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 20) @synthesize gitSoad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 21) @synthesize refDiad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 22) a2cbabf5 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-25 22:29:39 +0100 23) - (id) initWithGiad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 24) {a2cbabf5 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-25 22:29:39 +0100 25) gitRepo = ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 26) needRefs =ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 27) gitSocket ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 28) return selad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 29) }ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 30) ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 31) - (bool) uploadPaf344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 32) {f344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 33) NSLog(@"upf344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 34) NSString *f344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 35) NSArray *tf344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 36) 56ef2caf Source/Network/GITServerHandler.m (Scott Chacon 2009-01-05 21:44:26 -0800 37) refDict = f344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 38)

Page 564: Git 101 tutorial presentation

f344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 12) f344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 13) #define PACK_SIGNf344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 14) #define PACK_VERSf344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 15) ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 16) @implementation Gad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 17) ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 18) @synthesize gitRead11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 19) @synthesize needRad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 20) @synthesize gitSoad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 21) @synthesize refDiad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 22) a2cbabf5 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-25 22:29:39 +0100 23) - (id) initWithGiad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 24) {a2cbabf5 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-25 22:29:39 +0100 25) gitRepo = ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 26) needRefs =ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 27) gitSocket ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 28) return selad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 29) }ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 30) ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 31) - (bool) uploadPaf344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 32) {f344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 33) NSLog(@"upf344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 34) NSString *f344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 35) NSArray *tf344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 36) 56ef2caf Source/Network/GITServerHandler.m (Scott Chacon 2009-01-05 21:44:26 -0800 37) refDict = f344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 38)

git blame -C GITPackUpload.m

Page 565: Git 101 tutorial presentation

f344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 12) f344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 13) #define PACK_SIGNf344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 14) #define PACK_VERSf344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 15) ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 16) @implementation Gad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 17) ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 18) @synthesize gitRead11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 19) @synthesize needRad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 20) @synthesize gitSoad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 21) @synthesize refDiad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 22) a2cbabf5 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-25 22:29:39 +0100 23) - (id) initWithGiad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 24) {a2cbabf5 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-25 22:29:39 +0100 25) gitRepo = ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 26) needRefs =ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 27) gitSocket ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 28) return selad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 29) }ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 30) ad11ac80 Source/Network/GITPackUpload.m (Scott Chacon 2009-03-24 18:32:50 +0100 31) - (bool) uploadPaf344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 32) {f344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 33) NSLog(@"upf344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 34) NSString *f344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 35) NSArray *tf344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 36) 56ef2caf Source/Network/GITServerHandler.m (Scott Chacon 2009-01-05 21:44:26 -0800 37) refDict = f344f58d Source/Network/GITServerHandler.m (Scott Chacon 2009-01-04 18:59:04 -0800 38)

git blame -C GITPackUpload.m

Page 566: Git 101 tutorial presentation

Bisecting

Page 567: Git 101 tutorial presentation

binary search for where a bug was introduced

Page 568: Git 101 tutorial presentation

$ git bisect start$ git bisect bad$ git bisect good 3acb4c2c6666ed6cb91cb0b983efe9d50cf8cfbeBisecting: 6 revisions left to test after this[ecb6e1bc347ccecc5f9350d878ce677feb13d3b2] error handling on repo$ git bisect goodBisecting: 3 revisions left to test after this[b047b02ea83310a70fd603dc8cd7a6cd13d15c04] secure this thing$ git bisect badBisecting: 1 revisions left to test after this[f71ce38690acf49c1f3c9bea38e09d82a5ce6014] drop exceptions table and$ git bisect goodb047b02ea83310a70fd603dc8cd7a6cd13d15c04 is first bad commitcommit b047b02ea83310a70fd603dc8cd7a6cd13d15c04Author: PJ Hyett <[email protected]>Date: Tue Jan 27 14:48:32 2009 -0800

secure this thing

:040000 040000 40ee3e7821b895e52c1695092db9bdc4c61d1730 f24d3c6ebcfc639b1a3814550e62d60b8e68a8e4 M config

Page 569: Git 101 tutorial presentation

$ git bisect start$ git bisect bad$ git bisect good 3acb4c2c6666ed6cb91cb0b983efe9d50cf8cfbeBisecting: 6 revisions left to test after this[ecb6e1bc347ccecc5f9350d878ce677feb13d3b2] error handling on repo$ git bisect goodBisecting: 3 revisions left to test after this[b047b02ea83310a70fd603dc8cd7a6cd13d15c04] secure this thing$ git bisect badBisecting: 1 revisions left to test after this[f71ce38690acf49c1f3c9bea38e09d82a5ce6014] drop exceptions table and$ git bisect goodb047b02ea83310a70fd603dc8cd7a6cd13d15c04 is first bad commitcommit b047b02ea83310a70fd603dc8cd7a6cd13d15c04Author: PJ Hyett <[email protected]>Date: Tue Jan 27 14:48:32 2009 -0800

secure this thing

:040000 040000 40ee3e7821b895e52c1695092db9bdc4c61d1730 f24d3c6ebcfc639b1a3814550e62d60b8e68a8e4 M config

Page 570: Git 101 tutorial presentation

$ git bisect start$ git bisect bad$ git bisect good 3acb4c2c6666ed6cb91cb0b983efe9d50cf8cfbeBisecting: 6 revisions left to test after this[ecb6e1bc347ccecc5f9350d878ce677feb13d3b2] error handling on repo$ git bisect goodBisecting: 3 revisions left to test after this[b047b02ea83310a70fd603dc8cd7a6cd13d15c04] secure this thing$ git bisect badBisecting: 1 revisions left to test after this[f71ce38690acf49c1f3c9bea38e09d82a5ce6014] drop exceptions table and$ git bisect goodb047b02ea83310a70fd603dc8cd7a6cd13d15c04 is first bad commitcommit b047b02ea83310a70fd603dc8cd7a6cd13d15c04Author: PJ Hyett <[email protected]>Date: Tue Jan 27 14:48:32 2009 -0800

secure this thing

:040000 040000 40ee3e7821b895e52c1695092db9bdc4c61d1730 f24d3c6ebcfc639b1a3814550e62d60b8e68a8e4 M config

Page 571: Git 101 tutorial presentation

$ git bisect start$ git bisect bad$ git bisect good 3acb4c2c6666ed6cb91cb0b983efe9d50cf8cfbeBisecting: 6 revisions left to test after this[ecb6e1bc347ccecc5f9350d878ce677feb13d3b2] error handling on repo$ git bisect goodBisecting: 3 revisions left to test after this[b047b02ea83310a70fd603dc8cd7a6cd13d15c04] secure this thing$ git bisect badBisecting: 1 revisions left to test after this[f71ce38690acf49c1f3c9bea38e09d82a5ce6014] drop exceptions table and$ git bisect goodb047b02ea83310a70fd603dc8cd7a6cd13d15c04 is first bad commitcommit b047b02ea83310a70fd603dc8cd7a6cd13d15c04Author: PJ Hyett <[email protected]>Date: Tue Jan 27 14:48:32 2009 -0800

secure this thing

:040000 040000 40ee3e7821b895e52c1695092db9bdc4c61d1730 f24d3c6ebcfc639b1a3814550e62d60b8e68a8e4 M config

Page 572: Git 101 tutorial presentation

$ git bisect start$ git bisect bad$ git bisect good 3acb4c2c6666ed6cb91cb0b983efe9d50cf8cfbeBisecting: 6 revisions left to test after this[ecb6e1bc347ccecc5f9350d878ce677feb13d3b2] error handling on repo$ git bisect goodBisecting: 3 revisions left to test after this[b047b02ea83310a70fd603dc8cd7a6cd13d15c04] secure this thing$ git bisect badBisecting: 1 revisions left to test after this[f71ce38690acf49c1f3c9bea38e09d82a5ce6014] drop exceptions table and$ git bisect goodb047b02ea83310a70fd603dc8cd7a6cd13d15c04 is first bad commitcommit b047b02ea83310a70fd603dc8cd7a6cd13d15c04Author: PJ Hyett <[email protected]>Date: Tue Jan 27 14:48:32 2009 -0800

secure this thing

:040000 040000 40ee3e7821b895e52c1695092db9bdc4c61d1730 f24d3c6ebcfc639b1a3814550e62d60b8e68a8e4 M config

Page 573: Git 101 tutorial presentation

$ git bisect start$ git bisect bad$ git bisect good 3acb4c2c6666ed6cb91cb0b983efe9d50cf8cfbeBisecting: 6 revisions left to test after this[ecb6e1bc347ccecc5f9350d878ce677feb13d3b2] error handling on repo$ git bisect goodBisecting: 3 revisions left to test after this[b047b02ea83310a70fd603dc8cd7a6cd13d15c04] secure this thing$ git bisect badBisecting: 1 revisions left to test after this[f71ce38690acf49c1f3c9bea38e09d82a5ce6014] drop exceptions table and$ git bisect goodb047b02ea83310a70fd603dc8cd7a6cd13d15c04 is first bad commitcommit b047b02ea83310a70fd603dc8cd7a6cd13d15c04Author: PJ Hyett <[email protected]>Date: Tue Jan 27 14:48:32 2009 -0800

secure this thing

:040000 040000 40ee3e7821b895e52c1695092db9bdc4c61d1730 f24d3c6ebcfc639b1a3814550e62d60b8e68a8e4 M config

Page 574: Git 101 tutorial presentation

$ git bisect start$ git bisect bad$ git bisect good 3acb4c2c6666ed6cb91cb0b983efe9d50cf8cfbeBisecting: 6 revisions left to test after this[ecb6e1bc347ccecc5f9350d878ce677feb13d3b2] error handling on repo$ git bisect goodBisecting: 3 revisions left to test after this[b047b02ea83310a70fd603dc8cd7a6cd13d15c04] secure this thing$ git bisect badBisecting: 1 revisions left to test after this[f71ce38690acf49c1f3c9bea38e09d82a5ce6014] drop exceptions table and$ git bisect goodb047b02ea83310a70fd603dc8cd7a6cd13d15c04 is first bad commitcommit b047b02ea83310a70fd603dc8cd7a6cd13d15c04Author: PJ Hyett <[email protected]>Date: Tue Jan 27 14:48:32 2009 -0800

secure this thing

:040000 040000 40ee3e7821b895e52c1695092db9bdc4c61d1730 f24d3c6ebcfc639b1a3814550e62d60b8e68a8e4 M config

Page 575: Git 101 tutorial presentation

$ git bisect start$ git bisect bad$ git bisect good 3acb4c2c6666ed6cb91cb0b983efe9d50cf8cfbeBisecting: 6 revisions left to test after this[ecb6e1bc347ccecc5f9350d878ce677feb13d3b2] error handling on repo$ git bisect goodBisecting: 3 revisions left to test after this[b047b02ea83310a70fd603dc8cd7a6cd13d15c04] secure this thing$ git bisect badBisecting: 1 revisions left to test after this[f71ce38690acf49c1f3c9bea38e09d82a5ce6014] drop exceptions table$ git bisect goodb047b02ea83310a70fd603dc8cd7a6cd13d15c04 is first bad commitcommit b047b02ea83310a70fd603dc8cd7a6cd13d15c04Author: PJ Hyett <[email protected]>Date: Tue Jan 27 14:48:32 2009 -0800

secure this thing

:040000 040000 40ee3e7821b895e52c1695092db9bdc4c61d1730 f24d3c6ebcfc639b1a3814550e62d60b8e68a8e4 M config

Page 576: Git 101 tutorial presentation

$ git bisect start$ git bisect bad$ git bisect good 3acb4c2c6666ed6cb91cb0b983efe9d50cf8cfbeBisecting: 6 revisions left to test after this[ecb6e1bc347ccecc5f9350d878ce677feb13d3b2] error handling on repo$ git bisect goodBisecting: 3 revisions left to test after this[b047b02ea83310a70fd603dc8cd7a6cd13d15c04] secure this thing$ git bisect badBisecting: 1 revisions left to test after this[f71ce38690acf49c1f3c9bea38e09d82a5ce6014] drop exceptions table$ git bisect goodb047b02ea83310a70fd603dc8cd7a6cd13d15c04 is first bad commitcommit b047b02ea83310a70fd603dc8cd7a6cd13d15c04Author: PJ Hyett <[email protected]>Date: Tue Jan 27 14:48:32 2009 -0800

secure this thing

:040000 040000 40ee3e7821b895e52c1695092db9bdc4c61d1730 f24d3c6ebcfc639b1a3814550e62d60b8e68a8e4 M config

Page 577: Git 101 tutorial presentation

$ git bisect start$ git bisect bad$ git bisect good 3acb4c2c6666ed6cb91cb0b983efe9d50cf8cfbeBisecting: 6 revisions left to test after this[ecb6e1bc347ccecc5f9350d878ce677feb13d3b2] error handling on repo$ git bisect goodBisecting: 3 revisions left to test after this[b047b02ea83310a70fd603dc8cd7a6cd13d15c04] secure this thing$ git bisect badBisecting: 1 revisions left to test after this[f71ce38690acf49c1f3c9bea38e09d82a5ce6014] drop exceptions table$ git bisect goodb047b02ea83310a70fd603dc8cd7a6cd13d15c04 is first bad commitcommit b047b02ea83310a70fd603dc8cd7a6cd13d15c04Author: PJ Hyett <[email protected]>Date: Tue Jan 27 14:48:32 2009 -0800

secure this thing

:040000 040000 40ee3e7821b895e52c1695092db9bdc4c61d1730 f24d3c6ebcfc639b1a3814550e62d60b8e68a8e4 M config

Page 578: Git 101 tutorial presentation

$ git bisect start$ git bisect bad$ git bisect good 3acb4c2c6666ed6cb91cb0b983efe9d50cf8cfbeBisecting: 6 revisions left to test after this[ecb6e1bc347ccecc5f9350d878ce677feb13d3b2] error handling on repo$ git bisect goodBisecting: 3 revisions left to test after this[b047b02ea83310a70fd603dc8cd7a6cd13d15c04] secure this thing$ git bisect badBisecting: 1 revisions left to test after this[f71ce38690acf49c1f3c9bea38e09d82a5ce6014] drop exceptions table$ git bisect goodb047b02ea83310a70fd603dc8cd7a6cd13d15c04 is first bad commitcommit b047b02ea83310a70fd603dc8cd7a6cd13d15c04Author: PJ Hyett <[email protected]>Date: Tue Jan 27 14:48:32 2009 -0800

secure this thing

:040000 040000 40ee3e7821b895e52c1695092db9bdc4c61d1730 f24d3c6ebcfc639b1a3814550e62d60b8e68a8e4 M config

Page 579: Git 101 tutorial presentation

$ git bisect reset

Page 580: Git 101 tutorial presentation

Rebasing

Page 581: Git 101 tutorial presentation

Rewriting History

Page 582: Git 101 tutorial presentation

Modifying the last commit

Page 583: Git 101 tutorial presentation

git commit --amend

Page 584: Git 101 tutorial presentation

Rebasing

Page 585: Git 101 tutorial presentation

C1

C4

C5

C2

C3

master topic

Page 586: Git 101 tutorial presentation

git merge masterC1

C4

C5

C2

C3

master

topic

C6

Page 587: Git 101 tutorial presentation

C1

C4

C5

C2

C3

master topic

git rebase master

Page 588: Git 101 tutorial presentation

C1

C4

C5

C2

C3

master topic

git rebase master

Page 589: Git 101 tutorial presentation

C1

C4

C5

C2

C3

master topic

git rebase master

Page 590: Git 101 tutorial presentation

C1

C4

C5

C2

C3

master topic

git rebase master

Page 591: Git 101 tutorial presentation

C1

C4

C5

C2

C3

master topic

git rebase master

git diff c2 c3 > 2-3.patch

Page 592: Git 101 tutorial presentation

diff --git a/test b/testindex 2eadcec..bd8c6c9 100644--- a/test+++ b/test@@ -1,2 +1,3 @@ version one version four+version fiveC1

C4

C5

C2

C3

master topic

git rebase master

git diff c2 c3 > 2-3.patch

Page 593: Git 101 tutorial presentation

2-3.patchC1

C4

C5

C2

C3

master topic

Page 594: Git 101 tutorial presentation

2-3.patchC1

C4

C5

C2

C3

master topic

git diff c1 c2 > 1-2.patch

Page 595: Git 101 tutorial presentation

2-3.patchC1

C4

C5

C2

C3

master topic

git diff c1 c2 > 1-2.patch1-2.patch

Page 596: Git 101 tutorial presentation

1-2.patch

2-3.patchC1

C4

C5

C2

C3

master topic

Page 597: Git 101 tutorial presentation

1-2.patch

2-3.patchC1

C4

C5

C2

C3

master topic

git rebase master

Page 598: Git 101 tutorial presentation

2-3.patchC1

C4

C5

C2

C3

master topic

git rebase master

1-2.patch

Page 599: Git 101 tutorial presentation

2-3.patch

git rebase master

C1

C4

C5

C2

C3

master

topic

C2'

Page 600: Git 101 tutorial presentation

2-3.patchgit rebase master

C1

C4

C5

C2

C3

master

topic

C2'

Page 601: Git 101 tutorial presentation

git rebase master

C1

C4

C5

C2

C3

master

topic

C2'

C3'

Page 602: Git 101 tutorial presentation

git rebase master

C1

C4

C5

C2

C3

master

topic

C2'

C3'

Page 603: Git 101 tutorial presentation

git rebase master

C1

C4

C5

C2

C3

master

topic

C2'

C3'

topic

C2'

C3'

C1

C4

C5

master

Page 604: Git 101 tutorial presentation

C1

C4

C5master

topic

C2'

C3'

git rebase master

topic

C2'

C3'

C1

C4

C5master

Page 605: Git 101 tutorial presentation

Fun with Rebasing

Page 606: Git 101 tutorial presentation

rebase --onto

Page 607: Git 101 tutorial presentation

Transplanting Topic Branches

Page 608: Git 101 tutorial presentation

C1 C2

master

Page 609: Git 101 tutorial presentation

C1 C2

master

C1 C2

C3

server

Page 610: Git 101 tutorial presentation

C1 C2

C3

C8 C9

client

C1 C2

master

server

Page 611: Git 101 tutorial presentation

C1 C2

server

C3 C4

C8

C10

C9

client

master

Page 612: Git 101 tutorial presentation

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

Page 613: Git 101 tutorial presentation

move your ‘client’ branch work to your

‘master’ branch

Page 614: Git 101 tutorial presentation

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

Page 615: Git 101 tutorial presentation

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

Page 616: Git 101 tutorial presentation

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase master

Page 617: Git 101 tutorial presentation

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase master

Page 618: Git 101 tutorial presentation

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase master

Page 619: Git 101 tutorial presentation

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase master

Page 620: Git 101 tutorial presentation

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase server

Page 621: Git 101 tutorial presentation

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase server

Page 622: Git 101 tutorial presentation

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase server

Page 623: Git 101 tutorial presentation

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase server

Page 624: Git 101 tutorial presentation

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase server --onto master

Page 625: Git 101 tutorial presentation

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase server --onto master

Page 626: Git 101 tutorial presentation

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase server --onto master

Page 627: Git 101 tutorial presentation

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase server --onto master

C8 C9

Page 628: Git 101 tutorial presentation

C8 C9C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

C8' C9'

client

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

Page 629: Git 101 tutorial presentation

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

C8' C9'

client

Page 630: Git 101 tutorial presentation

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

C8' C9'

client

git checkout servergit rebase master

Page 631: Git 101 tutorial presentation

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

C8' C9'

client

git checkout servergit rebase client

Page 632: Git 101 tutorial presentation

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

C8' C9'

client

git checkout servergit rebase client

Page 633: Git 101 tutorial presentation

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

C8' C9'

client

git checkout servergit rebase client

C1 C2 C5 C6 C8' C9'

client

C3' C4' C10'

Page 634: Git 101 tutorial presentation

git checkout servergit rebase client

C1 C2 C5 C6 C8' C9'

client

C3' C4' C10'C1 C2 C5 C6 C8' C9'

client server

C3' C4' C10'

master

Page 635: Git 101 tutorial presentation

C1 C2 C5 C6 C8' C9'

client server

C3' C4' C10'

git checkout servergit rebase client

master

Page 636: Git 101 tutorial presentation

transplant some of a topic branch

Page 637: Git 101 tutorial presentation

C1C0 C2

C3

master

topic

C4 C5

Page 638: Git 101 tutorial presentation

C1C0 C2

C3

master

topic

C4 C5

Page 639: Git 101 tutorial presentation

git branch newtopic C3

C1C0 C2

C3

master

topic

C4 C5

Page 640: Git 101 tutorial presentation

git branch newtopic C3

newtopic

C1C0 C2

C3

master

topic

C4 C5

Page 641: Git 101 tutorial presentation

git branch newtopic C3git rebase newtopic --onto master

newtopic

C1C0 C2

C3

master

topic

C4 C5

Page 642: Git 101 tutorial presentation

C1C0 C2

C3

master topic

C4 C5

C4' C5'

git branch newtopic C3git rebase newtopic --onto master

newtopic

Page 643: Git 101 tutorial presentation

Fixing a commit several back

Page 644: Git 101 tutorial presentation

git rebase -igit rebase --interactive

Page 645: Git 101 tutorial presentation

C1

C0

C2

C3

C4

default

Page 646: Git 101 tutorial presentation

C1

C0

C2

C3

C4

default

Page 647: Git 101 tutorial presentation

C1

C0

C2

C3

C4

default

default~2

Page 648: Git 101 tutorial presentation

C1

C0

C2

C3

C4

default

default~2

Page 649: Git 101 tutorial presentation

git rebase -i default~2^

Page 650: Git 101 tutorial presentation

git rebase -i default~2^

Page 651: Git 101 tutorial presentation

git rebase -i default~2^

Page 652: Git 101 tutorial presentation

pick 969c877 git apply --directory broken for new filespick b75271d git diff <tree>{3,}: do not reverse order of argspick 72d404d test-lib: fix broken printf

# Rebase f285a2d..5c283eb onto f285a2d## Commands:# p, pick = use commit# e, edit = use commit, but stop for amending# s, squash = use commit, but meld into previous commit## If you remove a line here THAT COMMIT WILL BE LOST.# However, if you remove everything, the rebase will be aborted.#~ ~ ~ ~ ~ "~/projects/git/.git/rebase-merge/git-rebase-todo" 14L, 472C

Page 653: Git 101 tutorial presentation

pick 969c877 git apply --directory broken for new filespick b75271d git diff <tree>{3,}: do not reverse order of argspick 72d404d test-lib: fix broken printf

# Rebase f285a2d..5c283eb onto f285a2d## Commands:# p, pick = use commit# e, edit = use commit, but stop for amending# s, squash = use commit, but meld into previous commit## If you remove a line here THAT COMMIT WILL BE LOST.# However, if you remove everything, the rebase will be aborted.#~ ~ ~ ~ ~ "~/projects/git/.git/rebase-merge/git-rebase-todo" 14L, 472C

C2

C3

C4

Page 654: Git 101 tutorial presentation

pick 969c877 git apply --directory broken for new filespick b75271d git diff <tree>{3,}: do not reverse order of argspick 72d404d test-lib: fix broken printf

# Rebase f285a2d..5c283eb onto f285a2d## Commands:# p, pick = use commit# e, edit = use commit, but stop for amending# s, squash = use commit, but meld into previous commit## If you remove a line here THAT COMMIT WILL BE LOST.# However, if you remove everything, the rebase will be aborted.#~ ~ ~ ~ ~ "~/projects/git/.git/rebase-merge/git-rebase-todo" 14L, 472C

Page 655: Git 101 tutorial presentation

pick 969c877 git apply --directory broken for new filespick b75271d git diff <tree>{3,}: do not reverse order of argspick 72d404d test-lib: fix broken printf

# Rebase f285a2d..5c283eb onto f285a2d## Commands:# p, pick = use commit# e, edit = use commit, but stop for amending# s, squash = use commit, but meld into previous commit## If you remove a line here THAT COMMIT WILL BE LOST.# However, if you remove everything, the rebase will be aborted.#~ ~ ~ ~ ~ "~/projects/git/.git/rebase-merge/git-rebase-todo" 14L, 472C

Page 656: Git 101 tutorial presentation

pick 969c877 git apply --directory broken for new filespick b75271d git diff <tree>{3,}: do not reverse order of argspick 72d404d test-lib: fix broken printf

# Rebase f285a2d..5c283eb onto f285a2d## Commands:# p, pick = use commit# e, edit = use commit, but stop for amending# s, squash = use commit, but meld into previous commit## If you remove a line here THAT COMMIT WILL BE LOST.# However, if you remove everything, the rebase will be aborted.#~ ~ ~ ~ ~ "~/projects/git/.git/rebase-merge/git-rebase-todo" 14L, 472C

Page 657: Git 101 tutorial presentation

pick 969c877 git apply --directory broken for new filespick b75271d git diff <tree>{3,}: do not reverse order of argspick 72d404d test-lib: fix broken printf

# Rebase f285a2d..5c283eb onto f285a2d## Commands:# p, pick = use commit# e, edit = use commit, but stop for amending# s, squash = use commit, but meld into previous commit## If you remove a line here THAT COMMIT WILL BE LOST.# However, if you remove everything, the rebase will be aborted.#~ ~ ~ ~ ~ "~/projects/git/.git/rebase-merge/git-rebase-todo" 14L, 472C

Page 658: Git 101 tutorial presentation

pick 969c877 git apply --directory broken for new filespick b75271d git diff <tree>{3,}: do not reverse order of argspick 72d404d test-lib: fix broken printf

# Rebase f285a2d..5c283eb onto f285a2d## Commands:# p, pick = use commit# e, edit = use commit, but stop for amending# s, squash = use commit, but meld into previous commit## If you remove a line here THAT COMMIT WILL BE LOST.# However, if you remove everything, the rebase will be aborted.#~ ~ ~ ~ ~ "~/projects/git/.git/rebase-merge/git-rebase-todo" 14L, 472C

Page 659: Git 101 tutorial presentation

edit 969c877 git apply --directory broken for new filespick b75271d git diff <tree>{3,}: do not reverse order of argspick 72d404d test-lib: fix broken printf

# Rebase f285a2d..5c283eb onto f285a2d## Commands:# p, pick = use commit# e, edit = use commit, but stop for amending# s, squash = use commit, but meld into previous commit## If you remove a line here THAT COMMIT WILL BE LOST.# However, if you remove everything, the rebase will be aborted.#~ ~ ~ ~ ~ "~/projects/git/.git/rebase-merge/git-rebase-todo" 14L, 472C

Page 660: Git 101 tutorial presentation

$ git rebase -i default~2^Stopped at 969c877... git apply --directory broken for new filesYou can amend the commit now, with

git commit --amend

Once you are satisfied with your changes, run

git rebase --continue

$_

Page 661: Git 101 tutorial presentation

$ git rebase -i default~2^Stopped at 969c877... git apply --directory broken for new filesYou can amend the commit now, with

git commit --amend

Once you are satisfied with your changes, run

git rebase --continue

$_

edit filesgit add

git commit --amendgit rebase --continue

Page 662: Git 101 tutorial presentation

$ git rebase -i default~2^Stopped at 969c877... git apply --directory broken for new filesYou can amend the commit now, with

git commit --amend

Once you are satisfied with your changes, run

git rebase --continue

$_

edit filesgit add

git commit --amendgit rebase --continue

Page 663: Git 101 tutorial presentation

$ git rebase -i default~2^Stopped at 969c877... git apply --directory broken for new filesYou can amend the commit now, with

git commit --amend

Once you are satisfied with your changes, run

git rebase --continue

$_

edit filesgit add

git commit --amendgit rebase --continue

Page 664: Git 101 tutorial presentation

$ git rebase -i default~2^Stopped at 969c877... git apply --directory broken for new filesYou can amend the commit now, with

git commit --amend

Once you are satisfied with your changes, run

git rebase --continue

$_

edit filesgit add

git commit --amendgit rebase --continue

Page 665: Git 101 tutorial presentation

C1

C0

C2

C3

C4

default

C2'

C3'

C4'

Page 666: Git 101 tutorial presentation

C1

C0

C2

C3

C4

default

C2'

C3'

C4'

Page 667: Git 101 tutorial presentation

C1

C0

C2

C3

C4

default

C2'

C3'

C4'

Page 668: Git 101 tutorial presentation

Squashing commits together

Page 669: Git 101 tutorial presentation

pick 969c877 git apply --directory broken for new filespick b75271d git diff <tree>{3,}: do not reverse order of argspick 72d404d test-lib: fix broken printf

# Rebase f285a2d..5c283eb onto f285a2d## Commands:# p, pick = use commit# e, edit = use commit, but stop for amending# s, squash = use commit, but meld into previous commit## If you remove a line here THAT COMMIT WILL BE LOST.# However, if you remove everything, the rebase will be aborted.#~ ~ ~ ~ ~ "~/projects/git/.git/rebase-merge/git-rebase-todo" 14L, 472C

Page 670: Git 101 tutorial presentation

pick 969c877 git apply --directory broken for new filessquash b75271d git diff <tree>{3,}: do not reverse order of argssquash 72d404d test-lib: fix broken printf

# Rebase f285a2d..5c283eb onto f285a2d## Commands:# p, pick = use commit# e, edit = use commit, but stop for amending# s, squash = use commit, but meld into previous commit## If you remove a line here THAT COMMIT WILL BE LOST.# However, if you remove everything, the rebase will be aborted.#~ ~ ~ ~ ~ "~/projects/git/.git/rebase-merge/git-rebase-todo" 14L, 472C

Page 671: Git 101 tutorial presentation

# This is a combination of 3 commits.# The first commit's message is:git apply --directory broken for new files

# This is the 2nd commit message:

git diff <tree>{3,}: do not reverse order of args

# This is the 3rd commit message:

test-lib: fix broken printf

# Please enter the commit message for your changes. Lines starting# with '#' will be ignored, and an empty message aborts the commit.## Author: Jeff King <[email protected]>## Not currently on any branch.# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: builtin-apply.c# modified: builtin-diff.c# modified: t/t4013-diff-various.sh# new file: t/t4013/diff.diff_master_master^_side# modified: t/t4128-apply-root.sh# modified: t/test-lib.sh#~ ~ ".git/COMMIT_EDITMSG" 39L, 1454C

Page 672: Git 101 tutorial presentation

# This is a combination of 3 commits.# The first commit's message is:git apply --directory broken for new files

# This is the 2nd commit message:

git diff <tree>{3,}: do not reverse order of args

# This is the 3rd commit message:

test-lib: fix broken printf

# Please enter the commit message for your changes. Lines starting# with '#' will be ignored, and an empty message aborts the commit.## Author: Jeff King <[email protected]>## Not currently on any branch.# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: builtin-apply.c# modified: builtin-diff.c# modified: t/t4013-diff-various.sh# new file: t/t4013/diff.diff_master_master^_side# modified: t/t4128-apply-root.sh# modified: t/test-lib.sh#~ ~ ".git/COMMIT_EDITMSG" 39L, 1454C

Page 673: Git 101 tutorial presentation

# This is a combination of 3 commits.# The first commit's message is:git apply --directory broken for new files

# This is the 2nd commit message:

git diff <tree>{3,}: do not reverse order of args

# This is the 3rd commit message:

test-lib: fix broken printf

# Please enter the commit message for your changes. Lines starting# with '#' will be ignored, and an empty message aborts the commit.## Author: Jeff King <[email protected]>## Not currently on any branch.# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: builtin-apply.c# modified: builtin-diff.c# modified: t/t4013-diff-various.sh# new file: t/t4013/diff.diff_master_master^_side# modified: t/t4128-apply-root.sh# modified: t/test-lib.sh#~ ~ ".git/COMMIT_EDITMSG" 39L, 1454C

Page 674: Git 101 tutorial presentation

# This is a combination of 3 commits.# The first commit's message is:git apply --directory broken for new files

# This is the 2nd commit message:

git diff <tree>{3,}: do not reverse order of args

# This is the 3rd commit message:

test-lib: fix broken printf

# Please enter the commit message for your changes. Lines starting# with '#' will be ignored, and an empty message aborts the commit.## Author: Jeff King <[email protected]>## Not currently on any branch.# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: builtin-apply.c# modified: builtin-diff.c# modified: t/t4013-diff-various.sh# new file: t/t4013/diff.diff_master_master^_side# modified: t/t4128-apply-root.sh# modified: t/test-lib.sh#~ ~ ".git/COMMIT_EDITMSG" 39L, 1454C

Page 675: Git 101 tutorial presentation

C1

C0

C2

C3

C4

default

C5

Page 676: Git 101 tutorial presentation

The Perils

Page 677: Git 101 tutorial presentation

C1

C0

default

scott jessica

Page 678: Git 101 tutorial presentation

C0

default

scott jessica

C1

C0

scott/default

default

C2

C3

C4

C1

Page 679: Git 101 tutorial presentation

C0

C5

C6

C7

default

scott jessica

C1

C0

scott/default default

C2

C3

C4

C1

C5

C6

C7

Page 680: Git 101 tutorial presentation

C0

C5

C6

C7

default

scott jessica

C1

C0

scott/default

default

C2

C3

C4

C1

C5

C6

C7

C8

Page 681: Git 101 tutorial presentation

C0

C5

C6

C7

default

scott jessica

C1

C0

scott/default

default

C2

C3

C4

C1

C5

C6

C7

C5'

C6'

C7'

C8

Page 682: Git 101 tutorial presentation

C0

C5

C6

C7

default

scott jessica

C1

C0

scott/default

default

C2

C3

C4

C1

C5

C6

C7

C5'

C6'

C7'

C8

C5'

C6'

C7'

Page 683: Git 101 tutorial presentation

C0

C5

C6

C7

default

scott jessica

C1

C0

scott/default

default

C2

C3

C4

C1

C5

C6

C7

C5'

C6'

C7'

C8

C5'

C6'

C7'

C9

Page 684: Git 101 tutorial presentation

Filter BranchHistory Revision on Steroids

Page 685: Git 101 tutorial presentation

remove all instances of a file from every commit

Page 686: Git 101 tutorial presentation

git filter-branch --tree-filter 'rm -f filename'

HEAD

Page 687: Git 101 tutorial presentation

change your email in all commits

Page 688: Git 101 tutorial presentation

git filter-branch --env-filter "export [email protected]"

HEAD

Page 689: Git 101 tutorial presentation

git filter-branch --env-filter "export [email protected]"

origin/master..HEAD

Page 690: Git 101 tutorial presentation

Cherry Picking

Page 691: Git 101 tutorial presentation

git cherry-pick 3f40a

Page 692: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4 C8

C9C5

m/cupcake default

experiment

C10

Page 693: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4 C8

C9C5

m/cupcake default

experiment

C10

Page 694: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4 C8

C9C5

m/cupcake default

experiment

C10

Page 695: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4 C8

C9C5

m/cupcake default

experiment

C10

Page 696: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4 C8

C9C5

m/cupcake default

experiment

C10

git checkout default

Page 697: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4 C8

C9C5

m/cupcake default

experiment

C10

git cherry-pick c9

Page 698: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4 C8

C9C5

m/cupcake default

experiment

C10

git cherry-pick c9git cherry-pick experiment^

Page 699: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4 C8

C9C5

m/cupcake default

experiment

C10

git cherry-pick c9

Page 700: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4 C8

C9C5

m/cupcake

default experiment

C10C9'

Page 701: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4 C8

C9C5

m/cupcake

default experiment

C10C9'

git branch -d experiment

Page 702: Git 101 tutorial presentation

C1

C0

C2

C6

C7

C3

C4 C8

C9C5

m/cupcake

default experiment

C10C9'

Page 703: Git 101 tutorial presentation

Customizing

Page 704: Git 101 tutorial presentation

Colors

Page 705: Git 101 tutorial presentation

$ git config --global color.ui true

Page 706: Git 101 tutorial presentation

Custom Merge Tool

Page 707: Git 101 tutorial presentation

perforce visual merge tool

Page 708: Git 101 tutorial presentation
Page 709: Git 101 tutorial presentation

http://www.perforce.com/perforce/products/merge.html

Page 710: Git 101 tutorial presentation

$ cat /usr/local/bin/extMerge #!/bin/sh /Applications/p4merge.app/Contents/MacOS/p4merge $*

Page 711: Git 101 tutorial presentation

$ git config --global merge.tool extMerge

$ git config --global mergetool.extMerge.cmd 'extMerge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"'

$ git config --global mergetool.trustExitCode = false

Page 712: Git 101 tutorial presentation

[merge] tool = extMerge[mergetool "extMerge"] cmd = extMerge "$BASE" "$LOCAL" "$REMOTE" "$MERGED" trustExitCode = false

~/.gitconfig

Page 713: Git 101 tutorial presentation

git mergetool

Page 714: Git 101 tutorial presentation

Git Attributes

Page 715: Git 101 tutorial presentation

.gitattributes

Page 716: Git 101 tutorial presentation

Diff Binary Files

Page 717: Git 101 tutorial presentation

Images

Page 718: Git 101 tutorial presentation

diff --git a/image.png b/image.pngindex 88839c4..4afcb7c 100644Binary files a/image.png and b/image.png differ

Page 719: Git 101 tutorial presentation

tell Git how to diff a binary file

Page 720: Git 101 tutorial presentation

exiftool

Page 721: Git 101 tutorial presentation

$ echo '*.png diff=exif' >> .gitattributes$ git config diff.exif.textconv exiftool

Page 722: Git 101 tutorial presentation

$ echo '*.png diff=exif' >> .gitattributes$ git config diff.exif.textconv exiftool

every file that ends in .png

Page 723: Git 101 tutorial presentation

$ echo '*.png diff=exif' >> .gitattributes$ git config diff.exif.textconv exiftool

pre-process them with a strategy called ‘exif ’

Page 724: Git 101 tutorial presentation

$ echo '*.png diff=exif' >> .gitattributes$ git config diff.exif.textconv exiftool

Page 725: Git 101 tutorial presentation

$ echo '*.png diff=exif' >> .gitattributes$ git config diff.exif.textconv exiftool

the ‘exif ’ strategy is to run ‘exiftool’ on it

Page 726: Git 101 tutorial presentation

$ exiftool image.png ExifTool Version Number : 7.74File Name : image.pngDirectory : .File Size : 94 kBFile Modification Date/Time : 2009:04:21 07:02:43-07:00File Type : PNGMIME Type : image/pngImage Width : 1056Image Height : 827Bit Depth : 8Color Type : RGB with AlphaCompression : Deflate/InflateFilter : AdaptiveInterlace : NoninterlacedProfile CMM Type : applProfile Version : 2.0.0Profile Class : Display Device ProfileColor Space Data : RGBProfile Connection Space : XYZProfile Date Time : 2009:04:05 12:26:58Profile File Signature : acspPrimary Platform : Apple Computer Inc.CMM Flags : Not Embedded, IndependentDevice Manufacturer : Device Model : Device Attributes : Reflective, Glossy, Positive, ColorRendering Intent : PerceptualConnection Space Illuminant : 0.9642 1 0.82491Profile Creator : applProfile ID : 0Red Matrix Column : 0.39493 0.22505 0.02957Green Matrix Column : 0.42793 0.69208 0.14424Blue Matrix Column : 0.14134 0.08327 0.65096Media White Point : 0.95047 1 1.0891Chromatic Adaptation : 1.04788 0.02292 -0.0502 0.02957 0.99049 -0.01706 -0.00923 0.01508 0.75165Red Tone Reproduction Curve : (Binary data 14 bytes, use -b option to extract)Green Tone Reproduction Curve : (Binary data 14 bytes, use -b option to extract)Blue Tone Reproduction Curve : (Binary data 14 bytes, use -b option to extract)Video Card Gamma : (Binary data 1554 bytes, use -b option to extract)Native Display Info : (Binary data 1598 bytes, use -b option to extract)Profile Description : Color LCDProfile Description ML : Farge-LCDMake And Model : (Binary data 40 bytes, use -b option to extract)Profile Copyright : Copyright Apple, Inc., 2009Pixels Per Unit X : 5906Pixels Per Unit Y : 5906Pixel Units : MetersImage Size : 1056x827

Page 727: Git 101 tutorial presentation

$ echo '*.png diff=exif' >> .gitattributes$ git config diff.exif.textconv exiftool

Page 728: Git 101 tutorial presentation

diff --git a/image.png b/image.png index 88839c4..4afcb7c 100644 --- a/image.png +++ b/image.png @@ -1,12 +1,12 @@ ExifTool Version Number : 7.74 -File Size : 70 kB -File Modification Date/Time : 2009:04:21 07:02:45-07:00 +File Size : 94 kB +File Modification Date/Time : 2009:04:21 07:02:43-07:00 File Type : PNG MIME Type : image/png -Image Width : 1058 -Image Height : 889 +Image Width : 1056 +Image Height : 827 Bit Depth : 8 Color Type : RGB with Alpha

Page 729: Git 101 tutorial presentation

Documents

Page 730: Git 101 tutorial presentation

$ echo '*.doc diff=doc' >> .gitattributes$ git config diff.doc.textconv strings

Page 731: Git 101 tutorial presentation

$ git diff diff --git a/chapter1.doc b/chapter1.doc index c1c8a0a..b93c9e4 100644 --- a/chapter1.doc +++ b/chapter1.doc @@ -8,7 +8,8 @@ re going to cover Version Control Systems (VCS) and Git basics re going to cover how to get it and set it up for the first time if you don t already have it on your system. In Chapter Two we will go over basic Git usage - how to use Git for the 80% -s going on, modify stuff and contribute changes. If the book spontaneously +s going on, modify stuff and contribute changes. If the book spontaneously +Let's see if this works. Chapter Three is about the branching model in Git, often described as Git

Page 732: Git 101 tutorial presentation

$ git diff diff --git a/chapter1.doc b/chapter1.doc index c1c8a0a..b93c9e4 100644 --- a/chapter1.doc +++ b/chapter1.doc @@ -8,7 +8,8 @@ re going to cover Version Control Systems (VCS) and Git basics re going to cover how to get it and set it up for the first time if you don t already have it on your system. In Chapter Two we will go over basic Git usage - how to use Git for the 80% -s going on, modify stuff and contribute changes. If the book spontaneously +s going on, modify stuff and contribute changes. If the book spontaneously +Let's see if this works. Chapter Three is about the branching model in Git, often described as Git

Page 733: Git 101 tutorial presentation

File Filtering

Page 734: Git 101 tutorial presentation

Staging Area

fileA.txt

fileB.txt

fileC.rb

Page 735: Git 101 tutorial presentation

clean

smudge

*.txt Filter

Staging Area

fileA.txt

fileB.txt

fileC.rb

Page 736: Git 101 tutorial presentation

clean

smudge

*.txt Filter

Staging Area

fileA.txt

fileB.txt

fileC.rb

git checkout

Page 737: Git 101 tutorial presentation

Staging Area Working Directory

fileA.txt

fileB.txt clean

smudge fileA.txt'

fileB.txt'

*.txt Filter

fileC.rb fileC.rb

git checkout

Page 738: Git 101 tutorial presentation

Staging Area Working Directory

fileA.txt

fileB.txt clean

smudge fileA.txt'

fileB.txt'

*.txt Filter

fileC.rb fileC.rb

Page 739: Git 101 tutorial presentation

Staging Area Working Directory

fileA.txt

fileB.txt clean

smudge fileA.txt'

fileB.txt'

*.txt Filter

fileC.rb fileC.rb

git commit

Page 740: Git 101 tutorial presentation

Staging Area Working Directory

fileA.txt

fileB.txt clean

smudge fileA.txt'

fileB.txt'

*.txt Filter

fileC.rb fileC.rb

git commit

Page 741: Git 101 tutorial presentation

expanding a $Date$

Page 742: Git 101 tutorial presentation

#! /usr/bin/env rubydata = STDIN.readdate = `git log --pretty=format:"%ad" -1`puts data.gsub('$Date$', '$Date: ' + date + '$')

/usr/bin/expand_date

Page 743: Git 101 tutorial presentation

git config filter.dater.smudge expand_date

git config filter.dater.clean 'perl -pe "s/\\\$Date[^\\\$]*\\\$/\\\$Date\\\$/"'

Page 744: Git 101 tutorial presentation

git config filter.dater.smudge expand_date

git config filter.dater.clean 'perl -pe "s/\\\$Date[^\\\$]*\\\$/\\\$Date\\\$/"'

replace $Date(whatever)$ with $Date$

Page 745: Git 101 tutorial presentation

git config filter.dater.smudge expand_date

git config filter.dater.clean 'perl -pe "s/\\\$Date[^\\\$]*\\\$/\\\$Date\\\$/"'

replace $Date(whatever)$ with $Date$

Page 746: Git 101 tutorial presentation

test it

Page 747: Git 101 tutorial presentation

$ echo '# $Date$' > date_test.rb $ echo 'date*.rb filter=dater' >> .gitattributes

$ git add date_test.rb .gitattributes$ git commit -m "Testing date expansion in Git"$ rm date_test.rb$ git checkout date_test.rb$ cat date_test.rb# $Date: Tue Apr 21 07:26:52 2009 -0700$

Page 748: Git 101 tutorial presentation

$ echo '# $Date$' > date_test.rb $ echo 'date*.rb filter=dater' >> .gitattributes

$ git add date_test.rb .gitattributes$ git commit -m "Testing date expansion in Git"$ rm date_test.rb$ git checkout date_test.rb$ cat date_test.rb# $Date: Tue Apr 21 07:26:52 2009 -0700$

Page 749: Git 101 tutorial presentation

$ echo '# $Date$' > date_test.rb $ echo 'date*.rb filter=dater' >> .gitattributes

$ git add date_test.rb .gitattributes$ git commit -m "Testing date expansion in Git"$ rm date_test.rb$ git checkout date_test.rb$ cat date_test.rb# $Date: Tue Apr 21 07:26:52 2009 -0700$

use the ‘dater’ filter for any files matching ‘date*.rb’

Page 750: Git 101 tutorial presentation

$ echo '# $Date$' > date_test.rb $ echo 'date*.rb filter=dater' >> .gitattributes

$ git add date_test.rb .gitattributes$ git commit -m "Testing date expansion in Git"$ rm date_test.rb$ git checkout date_test.rb$ cat date_test.rb# $Date: Tue Apr 21 07:26:52 2009 -0700$

Page 751: Git 101 tutorial presentation

$ echo '# $Date$' > date_test.rb $ echo 'date*.rb filter=dater' >> .gitattributes

$ git add date_test.rb .gitattributes$ git commit -m "Testing date expansion in Git"$ rm date_test.rb$ git checkout date_test.rb$ cat date_test.rb# $Date: Tue Apr 21 07:26:52 2009 -0700$

Page 752: Git 101 tutorial presentation

$ echo '# $Date$' > date_test.rb $ echo 'date*.rb filter=dater' >> .gitattributes

$ git add date_test.rb .gitattributes$ git commit -m "Testing date expansion in Git"$ rm date_test.rb$ git checkout date_test.rb

$ cat date_test.rb# $Date: Tue Apr 21 07:26:52 2009 -0700$

Page 753: Git 101 tutorial presentation

$ git add date_test.rb .gitattributes$ git commit -m "Testing date expansion in Git"$ rm date_test.rb$ git checkout date_test.rb

$ cat date_test.rb# $Date: Tue Apr 21 07:26:52 2009 -0700$

$ echo '# $Date$' > date_test.rb $ echo 'date*.rb filter=dater' >> .gitattributes