Smacking Git Around Advanced Git Tricks

415
Smacking Git Around by Scott Chacon

description

 

Transcript of Smacking Git Around Advanced Git Tricks

Page 1: Smacking Git Around   Advanced Git Tricks

Smacking Git Aroundby Scott Chacon

Page 2: Smacking Git Around   Advanced Git Tricks

Me

Page 3: Smacking Git Around   Advanced Git Tricks

Scott Chacon

Page 4: Smacking Git Around   Advanced Git Tricks
Page 5: Smacking Git Around   Advanced Git Tricks

github.com/schacon

Page 6: Smacking Git Around   Advanced Git Tricks

“Scott Chacon has an understandable but borderline unhealthy obsession with Git”

- Ilya Grigorikigvita.com

Page 7: Smacking Git Around   Advanced Git Tricks

git-scm.com

Page 8: Smacking Git Around   Advanced Git Tricks
Page 9: Smacking Git Around   Advanced Git Tricks
Page 10: Smacking Git Around   Advanced Git Tricks

book.git-scm.com

Page 12: Smacking Git Around   Advanced Git Tricks

</me>

Page 13: Smacking Git Around   Advanced Git Tricks

previously, on Git...

Page 14: Smacking Git Around   Advanced Git Tricks

GIT

Page 15: Smacking Git Around   Advanced Git Tricks

Git

Page 16: Smacking Git Around   Advanced Git Tricks
Page 17: Smacking Git Around   Advanced Git Tricks

image by matthew mccullough

Page 18: Smacking Git Around   Advanced Git Tricks

Scott

v1

Scott ChaconScott Chacon

is a Git

v2 v3

Page 19: Smacking Git Around   Advanced Git Tricks
Page 20: Smacking Git Around   Advanced Git Tricks

commit size

98ca9..

tree

author

committer

initial commit of my project

0de24

Scott

Scott

commit size

34ac2..

tree

parent

author

committerfixed bug #1328 - stack

overflow under certain

184ca

98ca9

Scott

Scott

commit size

f30ab..

tree

parent

author

committeradd feature #32 - ability to

add new formats to the central

92ec2

34ac2

Scott

Scott

snapshot A snapshot B snapshot C

Page 21: Smacking Git Around   Advanced Git Tricks

blob size

e8455..commit size

98ca9..

== LICENSE:

(The MIT License)

Copyright (c) 2007 Tom Preston-

Permission is hereby granted, f

ree of charge, to any person ob

tree

parent

author

committermy commit message goes here

and it is really, really cool

0de24

nil

Scott

Scott

tree size

10af9..

blob

tree

bc52a

b70f8

mylib.rb

inc

tree size

b70f8..

blob 0ad1a tricks.rb

tree size

0de24..

blob

tree

e8455

10af9

README

lib

blob size

bc52a..

require 'grit/index'

require 'grit/status'

module Grit

class << self

attr_accessor :debug

blob size

0ad1a..

require 'grit/git-ruby/reposi

require 'grit/git-ruby/file_i

module Grit

module Tricks

0de24..

Page 22: Smacking Git Around   Advanced Git Tricks

blob size

e8455..commit size

98ca9..

== LICENSE:

(The MIT License)

Copyright (c) 2007 Tom Preston-

Permission is hereby granted, f

ree of charge, to any person ob

tree

parent

author

committermy commit message goes here

and it is really, really cool

0de24

nil

Scott

Scott

tree size

10af9..

blob

tree

bc52a

b70f8

mylib.rb

inc

tree size

b70f8..

blob 0ad1a tricks.rb

tree size

0de24..

blob

tree

e8455

10af9

README

lib

blob size

bc52a..

require 'grit/index'

require 'grit/status'

module Grit

class << self

attr_accessor :debug

blob size

0ad1a..

require 'grit/git-ruby/reposi

require 'grit/git-ruby/file_i

module Grit

module Tricks

0de24..

Page 23: Smacking Git Around   Advanced Git Tricks

0de24..22d8858e8513666bf91b82bd2939ec7b0d1974da

Page 24: Smacking Git Around   Advanced Git Tricks
Page 25: Smacking Git Around   Advanced Git Tricks

98ca9

a23fe

f30ab

master

34ac2

3acd1

topic

stable

Page 26: Smacking Git Around   Advanced Git Tricks

98ca9

a23fe

f30ab

master

34ac2

3acd1

topic

stable

Page 27: Smacking Git Around   Advanced Git Tricks

98ca9

a23fe

f30ab

master

34ac2

3acd1

topic

stable

Page 28: Smacking Git Around   Advanced Git Tricks

98ca9

a23fe

f30ab

master

34ac2

3acd1

topic

stable

Page 29: Smacking Git Around   Advanced Git Tricks

$ time git checkout -b newbranchSwitched to a new branch "newbranch"

real 0m0.040suser 0m0.003ssys0m0.008s

Page 30: Smacking Git Around   Advanced Git Tricks

$ time git checkout -b newbranchSwitched to a new branch "newbranch"

real 0m0.040suser 0m0.003ssys0m0.008s

Page 31: Smacking Git Around   Advanced Git Tricks
Page 32: Smacking Git Around   Advanced Git Tricks

master

develop

topic

Page 33: Smacking Git Around   Advanced Git Tricks
Page 34: Smacking Git Around   Advanced Git Tricks

distributed development

image by matthew mccullough

Page 35: Smacking Git Around   Advanced Git Tricks

ccf03da00eca1b60a489354c1278c27f1fbc55dca640106f173c5be59ed5757cf33f568b3e10994fc51a137df64b8ed2f8d84ad62df7b49b1c4099067e06f7f8d471d5ccbe958fcfaef0fc48ff1a3defdafe95908f7b9cbd2697f04544b68904a6c59aac2934b685f5dfd2b12c5d7d35d07c6058640f0581d3b47a90ef9bf2d7bbc5a7cf2b2f27eef4a08f04dbfeee0f5717d9978788da17cd6853316c92744a864734938d4044fc5e713e4818f60ecb4f4605253793a0108438a539f958236dbb9f4ea98b6b70ea00a60fa1439f082128c1ec03ec3c73acab074d316ba82b4879f04de35ffe2ef02d50df0adf184fad861020b6afeeec245afa2f864c72f5c2588295be505f3128a573bfe1d23aec2acef83c34c3cbd8be213e6f8761df038ab0b7c34a9fc4c2c3ce6c8b43798a8088bcc7cf47fdb33a9d79e398220b660f885e7c19d7b734f56900d9b92faad9eb74bedc3cf04aea3d0714150063b133e10ea987c5d95dce4aa2

Page 36: Smacking Git Around   Advanced Git Tricks
Page 37: Smacking Git Around   Advanced Git Tricks
Page 38: Smacking Git Around   Advanced Git Tricks

C

Page 39: Smacking Git Around   Advanced Git Tricks

fast

Page 40: Smacking Git Around   Advanced Git Tricks

efficient

Page 41: Smacking Git Around   Advanced Git Tricks
Page 42: Smacking Git Around   Advanced Git Tricks

100k repos

Page 43: Smacking Git Around   Advanced Git Tricks

80k users

Page 44: Smacking Git Around   Advanced Git Tricks
Page 45: Smacking Git Around   Advanced Git Tricks

</git-recap>

Page 46: Smacking Git Around   Advanced Git Tricks

Git Tips and Tricks

Page 47: Smacking Git Around   Advanced Git Tricks

Tips and Tricks

Selection and Ranges

Data Munging

Debugging

Customizing

Page 48: Smacking Git Around   Advanced Git Tricks

Selection and Ranges

Page 49: Smacking Git Around   Advanced Git Tricks

Revision Selection

Page 50: Smacking Git Around   Advanced Git Tricks

Revision Selection

alternate ways to refer to objects or ranges of objects

Page 51: Smacking Git Around   Advanced Git Tricks

Revision Selectionfull sha-1

partial sha-1

branch or tag name

caret parent

tilde spec

blob spec

relative specs

ranges

Page 52: Smacking Git Around   Advanced Git Tricks

Full SHA1

6e453f523fa1da50ecb04431101112b3611c6a4d

Page 53: Smacking Git Around   Advanced Git Tricks

Partial SHA16e453f523fa1da50ecb04431101112b3611c6a4d

6e453f523fa1da50

6e453

Page 54: Smacking Git Around   Advanced Git Tricks

Branch, Remote or Tag Name

v1.0

default

m/cupcake

Page 55: Smacking Git Around   Advanced Git Tricks

Caret Parent

default^2

2nd parent of ‘default’

Page 56: Smacking Git Around   Advanced Git Tricks

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

Page 57: Smacking Git Around   Advanced Git Tricks

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

master^

Page 58: Smacking Git Around   Advanced Git Tricks

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

master^2

Page 59: Smacking Git Around   Advanced Git Tricks

Tilde Spec

default~2

grandparent of ‘default’(parent of the parent)

Page 60: Smacking Git Around   Advanced Git Tricks

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

master~2

Page 61: Smacking Git Around   Advanced Git Tricks

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

master^^^2master~2^2

Page 62: Smacking Git Around   Advanced Git Tricks

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

master^^^2master~2^2

Page 63: Smacking Git Around   Advanced Git Tricks

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

master^^^2master~2^2

Page 64: Smacking Git Around   Advanced Git Tricks

Blob Spec

default:path/to/file

blob of that file in ‘default’ commit

Page 65: Smacking Git Around   Advanced Git Tricks

Relative Specs

master@{yesterday}

the commit ‘master’ was at yesterday

Page 66: Smacking Git Around   Advanced Git Tricks

Relative Specs

master@{5}

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

Page 67: Smacking Git Around   Advanced Git Tricks

Ranges

Page 68: Smacking Git Around   Advanced Git Tricks

Ranges

ce0e4..e4272

every commit reachable by e4272 that is not reachable by ce034

Page 69: Smacking Git Around   Advanced Git Tricks

Ranges

[old]..[new]

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

Page 70: Smacking Git Around   Advanced Git Tricks

Ranges

ce0e4..

everything since a commit

Page 71: Smacking Git Around   Advanced Git Tricks

“Reachability”

Page 72: Smacking Git Around   Advanced Git Tricks

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master..master

Page 73: Smacking Git Around   Advanced Git Tricks

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master..master

Page 74: Smacking Git Around   Advanced Git Tricks

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master..master

Page 75: Smacking Git Around   Advanced Git Tricks

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master..master

Page 76: Smacking Git Around   Advanced Git Tricks

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master..master

Page 77: Smacking Git Around   Advanced Git Tricks

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master..master

Page 78: Smacking Git Around   Advanced Git Tricks

jess/master..master

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

Page 79: Smacking Git Around   Advanced Git Tricks

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master..master

Page 80: Smacking Git Around   Advanced Git Tricks

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master..c36ae

Page 81: Smacking Git Around   Advanced Git Tricks

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master..c36ae

Page 82: Smacking Git Around   Advanced Git Tricks

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master..c36ae

Page 83: Smacking Git Around   Advanced Git Tricks

ce0e4

master

5ec47 2f45e 4eadf 2fbb3 18cae

b3be1 a09c6 df2fa c36ae

jess/master

jess/master..c36ae

Page 84: Smacking Git Around   Advanced Git Tricks

Advanced Log

Page 85: Smacking Git Around   Advanced Git Tricks

Log Subsets

Page 86: Smacking Git Around   Advanced Git Tricks

what am I going to push?

Page 87: Smacking Git Around   Advanced Git Tricks

git log origin/master..

Page 88: Smacking Git Around   Advanced Git Tricks

C1

C0

origin/master master HEAD

Page 89: Smacking Git Around   Advanced Git Tricks

C1

C0

C2

C3

C4

origin/master

master HEAD

Page 90: Smacking Git Around   Advanced Git Tricks

C1

C0

C2

C3

C4origin/master master HEAD

C5

C6

C7

git fetch origin

Page 91: Smacking Git Around   Advanced Git Tricks

C1

C0

C2

C3

C4origin/master master HEAD

C5

C6

C7

git log origin/master..

Page 92: Smacking Git Around   Advanced Git Tricks

C1

C0

C2

C3

C4origin/master master HEAD

C5

C6

C7

git log origin/master..HEAD

Page 93: Smacking Git Around   Advanced Git Tricks

C1

C0

C2

C3

C4origin/master master HEAD

C5

C6

C7

git log origin/master..HEAD

Page 94: Smacking Git Around   Advanced Git Tricks

C1

C0

C2

C3

C4origin/master master HEAD

C5

C6

C7

git log origin/master..HEAD

Page 95: Smacking Git Around   Advanced Git Tricks

C1

C0

C2

C3

C4origin/master master HEAD

C5

C6

C7

git log origin/master..HEAD

Page 96: Smacking Git Around   Advanced Git Tricks

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 97: Smacking Git Around   Advanced Git Tricks

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 98: Smacking Git Around   Advanced Git Tricks

C1

C0

C2

C3

C4origin/master master HEAD

C5

C6

C7

git log HEADorigin/master ..

Page 99: Smacking Git Around   Advanced Git Tricks

C1

C0

C2

C3

C4origin/master master HEAD

C5

C6

C7

git log HEAD origin/master..

Page 100: Smacking Git Around   Advanced Git Tricks

C1

C0

C2

C3

C4origin/master master HEAD

C5

C6

C7

git log HEAD origin/master..

“commits in origin/master not in HEAD”

Page 101: Smacking Git Around   Advanced Git Tricks

git log origin/master..

git log origin/master..HEAD

git log origin/master..master

git log master ^origin/master

git log master --not origin/master

Page 102: Smacking Git Around   Advanced Git Tricks

git log HEAD ^origin/master

Page 103: Smacking Git Around   Advanced Git Tricks

git log HEAD ^origin/master

Page 104: Smacking Git Around   Advanced Git Tricks

git log master topic1 ^origin/master

Page 105: Smacking Git Around   Advanced Git Tricks

C1

C0

origin/master

Page 106: Smacking Git Around   Advanced Git Tricks

C1

C0

C3

master

origin/master

Page 107: Smacking Git Around   Advanced Git Tricks

C1

C0

C3

C8

C9

master

experiment

C10

origin/master

Page 108: Smacking Git Around   Advanced Git Tricks

C1

C0

C2

C6

C7

C3

C4 C8

C9C5

origin/mastermaster

experiment

C10

Page 109: Smacking Git Around   Advanced Git Tricks

which changes aren’t in experiment?

Page 110: Smacking Git Around   Advanced Git Tricks

C1

C0

C2

C6

C7

C3

C4 C8

C9C5

origin/mastermaster

experiment

C10

git log origin/master master ^experiment

Page 111: Smacking Git Around   Advanced Git Tricks

git log origin/master master ^experiment

C1

C0

C2

C6

C7

C3

C4 C8

C9C5

origin/mastermaster

experiment

C10

Page 112: Smacking Git Around   Advanced Git Tricks

git log origin/master master ^experiment

C1

C0

C2

C6

C7

C3

C4 C8

C9C5

origin/mastermaster

experiment

C10

Page 113: Smacking Git Around   Advanced Git Tricks

git log origin/master master ^experiment

C1

C0

C2

C6

C7

C3

C4 C8

C9C5

origin/mastermaster

experiment

C10

Page 114: Smacking Git Around   Advanced Git Tricks

git log origin/master master ^experiment

C1

C0

C2

C6

C7

C3

C4 C8

C9C5

origin/mastermaster

experiment

C10

Page 115: Smacking Git Around   Advanced Git Tricks

git log origin/master master ^experiment

C1

C0

C2

C6

C7

C3

C4 C8

C9C5

origin/mastermaster

experiment

C10

Page 116: Smacking Git Around   Advanced Git Tricks

git log origin/master master ^experiment

C1

C0

C2

C6

C7

C3

C4 C8

C9C5

origin/mastermaster

experiment

C10

Page 117: Smacking Git Around   Advanced Git Tricks

git log --graph

Page 118: Smacking Git Around   Advanced Git Tricks

git log --pretty=oneline --graph

Page 119: Smacking Git Around   Advanced Git Tricks

gitk

Page 120: Smacking Git Around   Advanced Git Tricks

gitk 6d13f..41aba

Page 121: Smacking Git Around   Advanced Git Tricks

Revision Diffs

Page 122: Smacking Git Around   Advanced Git Tricks

git diff revA revB

Page 123: Smacking Git Around   Advanced Git Tricks

C1

master

$ echo ‘version one’ > test$ git add test$ git commit -m ‘C1’

Page 124: Smacking Git Around   Advanced Git Tricks

$ git checkout -b topic$ echo ‘version two’ >> test$ git commit -m ‘C2’

C1

C2master

topic

Page 125: Smacking Git Around   Advanced Git Tricks

$ echo ‘version three’ >> test$ git commit -m ‘C3’

C1

C2

C3

master

topic

Page 126: Smacking Git Around   Advanced Git Tricks

$ git checkout master$ echo ‘version four’ >> test$ git commit -m ‘C4’

C1

C4 C2

C3master

topic

Page 127: Smacking Git Around   Advanced Git Tricks

$ echo ‘version five’ >> test$ git commit -m ‘C5’

C1

C4

C5

C2

C3

master topic

Page 128: Smacking Git Around   Advanced Git Tricks

C1

C4

C5

C2

C3

master topic

$ git diff topic

Page 129: Smacking Git Around   Advanced Git Tricks

$ git diff topic

C1

C4

C5

C2

C3

master topic

what does topic have that I don’t have?

Page 130: Smacking Git Around   Advanced Git Tricks

$ git diff topic

C1

C4

C5

C2

C3

master topic

what would happen if I merged in topic?

Page 131: Smacking Git Around   Advanced Git Tricks

$ git diff topic

C1

C4

C5

C2

C3

master topic

how do I make topic look like HEAD?

Page 132: Smacking Git Around   Advanced Git Tricks

$ git diff topic

C1

C4

C5

C2

C3

master topicdiff --git a/test b/testindex 304313d..bd8c6c9 100644--- a/test+++ b/test@@ -1,3 +1,3 @@ version one-version two-version three+version four+version five

Page 133: Smacking Git Around   Advanced Git Tricks

$ git diff topic

C1

C4

C5

C2

C3

master topicdiff --git a/test b/testindex 304313d..bd8c6c9 100644--- a/test+++ b/test@@ -1,3 +1,3 @@ version one-version two-version three+version four+version five

Page 134: Smacking Git Around   Advanced Git Tricks

$ git diff HEAD topic

C1

C4

C5

C2

C3

master topicdiff --git a/test b/testindex bd8c6c9..304313d 100644--- a/test+++ b/test@@ -1,3 +1,3 @@ version one-version four-version five+version two+version three

Page 135: Smacking Git Around   Advanced Git Tricks

$ git diff HEAD topic

C1

C4

C5

C2

C3

master topicdiff --git a/test b/testindex bd8c6c9..304313d 100644--- a/test+++ b/test@@ -1,3 +1,3 @@ version one-version four-version five+version two+version three

Page 136: Smacking Git Around   Advanced Git Tricks

git diff HEAD topic

Page 137: Smacking Git Around   Advanced Git Tricks

git diff HEAD...topic

Page 138: Smacking Git Around   Advanced Git Tricks

git diff HEAD...topic

Page 139: Smacking Git Around   Advanced Git Tricks

$ git diff HEAD topic

C1

C4

C5

C2

C3

master topic

Page 140: Smacking Git Around   Advanced Git Tricks

$ git diff HEAD topic

C1

C4

C5

C2

C3

master topic

Page 141: Smacking Git Around   Advanced Git Tricks

$ git diff HEAD...topic

C1

C4

C5

C2

C3

master topic

Page 142: Smacking Git Around   Advanced Git Tricks

$ git diff HEAD...topic

C1

C4

C5

C2

C3

master topic

diff --git a/test b/testindex 9bc69cf..304313d 100644--- a/test+++ b/test@@ -1 +1,3 @@ version one+version two+version three

Page 143: Smacking Git Around   Advanced Git Tricks

$ git diff HEAD...topic

C1

C4

C5

C2

C3

master topic

diff --git a/test b/testindex 9bc69cf..304313d 100644--- a/test+++ b/test@@ -1 +1,3 @@ version one+version two+version three

what would happen if I merged in topic?

Page 144: Smacking Git Around   Advanced Git Tricks

Data Munging

Page 145: Smacking Git Around   Advanced Git Tricks

Rewriting History

Page 146: Smacking Git Around   Advanced Git Tricks

Modifying the last commit

Page 147: Smacking Git Around   Advanced Git Tricks

git commit --amend

Page 148: Smacking Git Around   Advanced Git Tricks

Rebasing

Page 149: Smacking Git Around   Advanced Git Tricks

C1

C4

C5

C2

C3

master topic

Page 150: Smacking Git Around   Advanced Git Tricks

git merge masterC1

C4

C5

C2

C3

master

topic

C6

Page 151: Smacking Git Around   Advanced Git Tricks

C1

C4

C5

C2

C3

master topic

git rebase master

Page 152: Smacking Git Around   Advanced Git Tricks

C1

C4

C5

C2

C3

master topic

git rebase master

Page 153: Smacking Git Around   Advanced Git Tricks

C1

C4

C5

C2

C3

master topic

git rebase master

Page 154: Smacking Git Around   Advanced Git Tricks

C1

C4

C5

C2

C3

master topic

git rebase master

Page 155: Smacking Git Around   Advanced Git Tricks

C1

C4

C5

C2

C3

master topic

git rebase master

git diff c2 c3 > 2-3.patch

Page 156: Smacking Git Around   Advanced Git Tricks

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 157: Smacking Git Around   Advanced Git Tricks

2-3.patchC1

C4

C5

C2

C3

master topic

Page 158: Smacking Git Around   Advanced Git Tricks

2-3.patchC1

C4

C5

C2

C3

master topic

git diff c1 c2 > 1-2.patch

Page 159: Smacking Git Around   Advanced Git Tricks

2-3.patchC1

C4

C5

C2

C3

master topic

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

Page 160: Smacking Git Around   Advanced Git Tricks

1-2.patch

2-3.patchC1

C4

C5

C2

C3

master topic

Page 161: Smacking Git Around   Advanced Git Tricks

1-2.patch

2-3.patchC1

C4

C5

C2

C3

master topic

git rebase master

Page 162: Smacking Git Around   Advanced Git Tricks

2-3.patchC1

C4

C5

C2

C3

master topic

git rebase master

1-2.patch

Page 163: Smacking Git Around   Advanced Git Tricks

2-3.patch

git rebase master

C1

C4

C5

C2

C3

master

topic

C2'

Page 164: Smacking Git Around   Advanced Git Tricks

2-3.patchgit rebase master

C1

C4

C5

C2

C3

master

topic

C2'

Page 165: Smacking Git Around   Advanced Git Tricks

git rebase master

C1

C4

C5

C2

C3

master

topic

C2'

C3'

Page 166: Smacking Git Around   Advanced Git Tricks

git rebase master

C1

C4

C5

C2

C3

master

topic

C2'

C3'

Page 167: Smacking Git Around   Advanced Git Tricks

git rebase master

C1

C4

C5

C2

C3

master

topic

C2'

C3'

topic

C2'

C3'

C1

C4

C5

master

Page 168: Smacking Git Around   Advanced Git Tricks

C1

C4

C5master

topic

C2'

C3'

git rebase master

topic

C2'

C3'

C1

C4

C5master

Page 169: Smacking Git Around   Advanced Git Tricks

Fun with Rebasing

Page 170: Smacking Git Around   Advanced Git Tricks

rebase --onto

Page 171: Smacking Git Around   Advanced Git Tricks

Transplanting Topic Branches

Page 172: Smacking Git Around   Advanced Git Tricks

C1 C2

master

Page 173: Smacking Git Around   Advanced Git Tricks

C1 C2

master

C1 C2

C3

server

Page 174: Smacking Git Around   Advanced Git Tricks

C1 C2

C3

C8 C9

client

C1 C2

master

server

Page 175: Smacking Git Around   Advanced Git Tricks

C1 C2

server

C3 C4

C8

C10

C9

client

master

Page 176: Smacking Git Around   Advanced Git Tricks

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

Page 177: Smacking Git Around   Advanced Git Tricks

move your ‘client’ branch work to your

‘master’ branch

Page 178: Smacking Git Around   Advanced Git Tricks

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

Page 179: Smacking Git Around   Advanced Git Tricks

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

Page 180: Smacking Git Around   Advanced Git Tricks

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase master

Page 181: Smacking Git Around   Advanced Git Tricks

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase master

Page 182: Smacking Git Around   Advanced Git Tricks

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase master

Page 183: Smacking Git Around   Advanced Git Tricks

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase master

Page 184: Smacking Git Around   Advanced Git Tricks

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase server

Page 185: Smacking Git Around   Advanced Git Tricks

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase server

Page 186: Smacking Git Around   Advanced Git Tricks

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase server

Page 187: Smacking Git Around   Advanced Git Tricks

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase server

Page 188: Smacking Git Around   Advanced Git Tricks

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase --onto master server

Page 189: Smacking Git Around   Advanced Git Tricks

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase --onto master server

Page 190: Smacking Git Around   Advanced Git Tricks

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

git rebase --onto master server

Page 191: Smacking Git Around   Advanced Git Tricks

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

client

C8 C9

git rebase --onto master server

Page 192: Smacking Git Around   Advanced Git Tricks

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 193: Smacking Git Around   Advanced Git Tricks

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

C8' C9'

client

Page 194: Smacking Git Around   Advanced Git Tricks

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

C8' C9'

client

git checkout servergit rebase master

Page 195: Smacking Git Around   Advanced Git Tricks

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

C8' C9'

client

git checkout servergit rebase client

Page 196: Smacking Git Around   Advanced Git Tricks

C1 C2 C5

server

C3

master

C4

C6

C8

C10

C9

C8' C9'

client

git checkout servergit rebase client

Page 197: Smacking Git Around   Advanced Git Tricks

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 198: Smacking Git Around   Advanced Git Tricks

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 199: Smacking Git Around   Advanced Git Tricks

C1 C2 C5 C6 C8' C9'

client server

C3' C4' C10'

git checkout servergit rebase client

master

Page 200: Smacking Git Around   Advanced Git Tricks

transplant some of a topic branch

Page 201: Smacking Git Around   Advanced Git Tricks

C1C0 C2

C3

master

topic

C4 C5

Page 202: Smacking Git Around   Advanced Git Tricks

C1C0 C2

C3

master

topic

C4 C5

Page 203: Smacking Git Around   Advanced Git Tricks

git branch newtopic C3

C1C0 C2

C3

master

topic

C4 C5

Page 204: Smacking Git Around   Advanced Git Tricks

git branch newtopic C3

newtopic

C1C0 C2

C3

master

topic

C4 C5

Page 205: Smacking Git Around   Advanced Git Tricks

git branch newtopic C3git rebase --onto master newtopic

newtopic

C1C0 C2

C3

master

topic

C4 C5

Page 206: Smacking Git Around   Advanced Git Tricks

C1C0 C2

C3

master topic

C4 C5

C4' C5'

git branch newtopic C3git rebase --onto master newtopic

newtopic

Page 207: Smacking Git Around   Advanced Git Tricks

Fixing a commit several back

Page 208: Smacking Git Around   Advanced Git Tricks

git rebase -igit rebase --interactive

Page 209: Smacking Git Around   Advanced Git Tricks

C1

C0

C2

C3

C4

default

Page 210: Smacking Git Around   Advanced Git Tricks

C1

C0

C2

C3

C4

default

Page 211: Smacking Git Around   Advanced Git Tricks

C1

C0

C2

C3

C4

default

default~2

Page 212: Smacking Git Around   Advanced Git Tricks

C1

C0

C2

C3

C4

default

default~2

Page 213: Smacking Git Around   Advanced Git Tricks

git rebase -i default~2^

Page 214: Smacking Git Around   Advanced Git Tricks

git rebase -i default~2^

Page 215: Smacking Git Around   Advanced Git Tricks

git rebase -i default~2^

Page 216: Smacking Git Around   Advanced Git Tricks

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 217: Smacking Git Around   Advanced Git Tricks

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 218: Smacking Git Around   Advanced Git Tricks

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 219: Smacking Git Around   Advanced Git Tricks

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 220: Smacking Git Around   Advanced Git Tricks

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 221: Smacking Git Around   Advanced Git Tricks

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 222: Smacking Git Around   Advanced Git Tricks

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 223: Smacking Git Around   Advanced Git Tricks

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 224: Smacking Git Around   Advanced Git Tricks

$ 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 225: Smacking Git Around   Advanced Git Tricks

$ 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 226: Smacking Git Around   Advanced Git Tricks

$ 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 227: Smacking Git Around   Advanced Git Tricks

$ 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 228: Smacking Git Around   Advanced Git Tricks

$ 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 229: Smacking Git Around   Advanced Git Tricks

C1

C0

C2

C3

C4

default

C2'

C3'

C4'

Page 230: Smacking Git Around   Advanced Git Tricks

C1

C0

C2

C3

C4

default

C2'

C3'

C4'

Page 231: Smacking Git Around   Advanced Git Tricks

C1

C0

C2

C3

C4

default

C2'

C3'

C4'

Page 232: Smacking Git Around   Advanced Git Tricks

Squashing commits together

Page 233: Smacking Git Around   Advanced Git Tricks

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 234: Smacking Git Around   Advanced Git Tricks

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 235: Smacking Git Around   Advanced Git Tricks

# 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 236: Smacking Git Around   Advanced Git Tricks

# 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 237: Smacking Git Around   Advanced Git Tricks

# 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 238: Smacking Git Around   Advanced Git Tricks

# 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 239: Smacking Git Around   Advanced Git Tricks

C1

C0

C2

C3

C4

default

C5

Page 240: Smacking Git Around   Advanced Git Tricks

The Perils

Page 241: Smacking Git Around   Advanced Git Tricks

C1

C0

default

scott jessica

Page 242: Smacking Git Around   Advanced Git Tricks

C0

default

scott jessica

C1

C0

scott/default

default

C2

C3

C4

C1

Page 243: Smacking Git Around   Advanced Git Tricks

C0

C5

C6

C7

default

scott jessica

C1

C0

scott/default default

C2

C3

C4

C1

C5

C6

C7

Page 244: Smacking Git Around   Advanced Git Tricks

C0

C5

C6

C7

default

scott jessica

C1

C0

scott/default

default

C2

C3

C4

C1

C5

C6

C7

C8

Page 245: Smacking Git Around   Advanced Git Tricks

C0

C5

C6

C7

default

scott jessica

C1

C0

scott/default

default

C2

C3

C4

C1

C5

C6

C7

C5'

C6'

C7'

C8

Page 246: Smacking Git Around   Advanced Git Tricks

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 247: Smacking Git Around   Advanced Git Tricks

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 248: Smacking Git Around   Advanced Git Tricks

Filter BranchHistory Revision on Steroids

Page 249: Smacking Git Around   Advanced Git Tricks

remove all instances of a file from every commit

Page 250: Smacking Git Around   Advanced Git Tricks

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

HEAD

Page 251: Smacking Git Around   Advanced Git Tricks

change your email in all commits

Page 252: Smacking Git Around   Advanced Git Tricks

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

HEAD

Page 253: Smacking Git Around   Advanced Git Tricks

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

origin/master..HEAD

Page 254: Smacking Git Around   Advanced Git Tricks

Subtree Merging

Page 255: Smacking Git Around   Advanced Git Tricks

Alternative to Submodules

Page 256: Smacking Git Around   Advanced Git Tricks

$ lsREADME rack_app.rb $ git remote add rack_remote [email protected]:schacon/rack.git$ git fetch rack_remotewarning: no common commitsremote: Counting objects: 3184, done.remote: Compressing objects: 100% (1465/1465), done.remote: Total 3184 (delta 1952), reused 2770 (delta 1675)Receiving objects: 100% (3184/3184), 677.42 KiB | 4 KiB/s, done.Resolving deltas: 100% (1952/1952), done.From [email protected]:schacon/rack * [new branch] master -> rack_remote/master$ git checkout -b rack_branch rack_remote/masterBranch rack_branch set up to track remote branch refs/remotes/rack_remote/master.Switched to a new branch "rack_branch"$ lsAUTHORS KNOWN-ISSUES Rakefile contrib libCOPYING README bin example test

Page 257: Smacking Git Around   Advanced Git Tricks

C1

C0

master

C2

C3

Page 258: Smacking Git Around   Advanced Git Tricks

$ lsREADME rack_app.rb $ git remote add rack_remote [email protected]:schacon/rack.git$ git fetch rack_remotewarning: no common commitsremote: Counting objects: 3184, done.remote: Compressing objects: 100% (1465/1465), done.remote: Total 3184 (delta 1952), reused 2770 (delta 1675)Receiving objects: 100% (3184/3184), 677.42 KiB | 4 KiB/s, done.Resolving deltas: 100% (1952/1952), done.From [email protected]:schacon/rack * [new branch] master -> rack_remote/master$ git checkout -b rack_branch rack_remote/masterBranch rack_branch set up to track remote branch refs/remotes/rack_remote/master.Switched to a new branch "rack_branch"$ lsAUTHORS KNOWN-ISSUES Rakefile contrib libCOPYING README bin example test

Page 259: Smacking Git Around   Advanced Git Tricks

$ lsREADME rack_app.rb $ git remote add rack_remote [email protected]:schacon/rack.git$ git fetch rack_remotewarning: no common commitsremote: Counting objects: 3184, done.remote: Compressing objects: 100% (1465/1465), done.remote: Total 3184 (delta 1952), reused 2770 (delta 1675)Receiving objects: 100% (3184/3184), 677.42 KiB | 4 KiB/s, done.Resolving deltas: 100% (1952/1952), done.From [email protected]:schacon/rack * [new branch] master -> rack_remote/master$ git checkout -b rack_branch rack_remote/masterBranch rack_branch set up to track remote branch refs/remotes/rack_remote/master.Switched to a new branch "rack_branch"$ lsAUTHORS KNOWN-ISSUES Rakefile contrib libCOPYING README bin example test

Page 260: Smacking Git Around   Advanced Git Tricks

$ lsREADME rack_app.rb $ git remote add rack_remote [email protected]:schacon/rack.git$ git fetch rack_remotewarning: no common commitsremote: Counting objects: 3184, done.remote: Compressing objects: 100% (1465/1465), done.remote: Total 3184 (delta 1952), reused 2770 (delta 1675)Receiving objects: 100% (3184/3184), 677.42 KiB | 4 KiB/s, done.Resolving deltas: 100% (1952/1952), done.From [email protected]:schacon/rack * [new branch] master -> rack_remote/master$ git checkout -b rack_branch rack_remote/masterBranch rack_branch set up to track remote branch refs/remotes/rack_remote/master.Switched to a new branch "rack_branch"$ lsAUTHORS KNOWN-ISSUES Rakefile contrib libCOPYING README bin example test

Page 261: Smacking Git Around   Advanced Git Tricks

$ lsREADME rack_app.rb $ git remote add rack_remote [email protected]:schacon/rack.git$ git fetch rack_remotewarning: no common commitsremote: Counting objects: 3184, done.remote: Compressing objects: 100% (1465/1465), done.remote: Total 3184 (delta 1952), reused 2770 (delta 1675)Receiving objects: 100% (3184/3184), 677.42 KiB | 4 KiB/s, done.Resolving deltas: 100% (1952/1952), done.From [email protected]:schacon/rack * [new branch] master -> rack_remote/master$ git checkout -b rack_branch rack_remote/masterBranch rack_branch set up to track remote branch refs/remotes/rack_remote/master.Switched to a new branch "rack_branch"$ lsAUTHORS KNOWN-ISSUES Rakefile contrib libCOPYING README bin example test

Page 262: Smacking Git Around   Advanced Git Tricks

$ lsREADME rack_app.rb $ git remote add rack_remote [email protected]:schacon/rack.git$ git fetch rack_remotewarning: no common commitsremote: Counting objects: 3184, done.remote: Compressing objects: 100% (1465/1465), done.remote: Total 3184 (delta 1952), reused 2770 (delta 1675)Receiving objects: 100% (3184/3184), 677.42 KiB | 4 KiB/s, done.Resolving deltas: 100% (1952/1952), done.From [email protected]:schacon/rack * [new branch] master -> rack_remote/master$ git checkout -b rack_branch rack_remote/masterBranch rack_branch set up to track remote branch refs/remotes/rack_remote/master.Switched to a new branch "rack_branch"$ lsAUTHORS KNOWN-ISSUES Rakefile contrib libCOPYING README bin example test

Page 263: Smacking Git Around   Advanced Git Tricks

$ lsREADME rack_app.rb $ git remote add rack_remote [email protected]:schacon/rack.git$ git fetch rack_remotewarning: no common commitsremote: Counting objects: 3184, done.remote: Compressing objects: 100% (1465/1465), done.remote: Total 3184 (delta 1952), reused 2770 (delta 1675)Receiving objects: 100% (3184/3184), 677.42 KiB | 4 KiB/s, done.Resolving deltas: 100% (1952/1952), done.From [email protected]:schacon/rack * [new branch] master -> rack_remote/master$ git checkout -b rack_branch rack_remote/masterBranch rack_branch set up to track remote branch refs/remotes/rack_remote/master.Switched to a new branch "rack_branch"$ lsAUTHORS KNOWN-ISSUES Rakefile contrib libCOPYING README bin example test

Page 264: Smacking Git Around   Advanced Git Tricks

$ lsREADME rack_app.rb $ git remote add rack_remote [email protected]:schacon/rack.git$ git fetch rack_remotewarning: no common commitsremote: Counting objects: 3184, done.remote: Compressing objects: 100% (1465/1465), done.remote: Total 3184 (delta 1952), reused 2770 (delta 1675)Receiving objects: 100% (3184/3184), 677.42 KiB | 4 KiB/s, done.Resolving deltas: 100% (1952/1952), done.From [email protected]:schacon/rack * [new branch] master -> rack_remote/master$ git checkout -b rack_branch rack_remote/masterBranch rack_branch set up to track remote branch refs/remotes/rack_remote/master.Switched to a new branch "rack_branch"$ lsAUTHORS KNOWN-ISSUES Rakefile contrib libCOPYING README bin example test

Page 265: Smacking Git Around   Advanced Git Tricks

$ lsREADME rack_app.rb $ git remote add rack_remote [email protected]:schacon/rack.git$ git fetch rack_remotewarning: no common commitsremote: Counting objects: 3184, done.remote: Compressing objects: 100% (1465/1465), done.remote: Total 3184 (delta 1952), reused 2770 (delta 1675)Receiving objects: 100% (3184/3184), 677.42 KiB | 4 KiB/s, done.Resolving deltas: 100% (1952/1952), done.From [email protected]:schacon/rack * [new branch] master -> rack_remote/master$ git checkout -b rack_branch rack_remote/masterBranch rack_branch set up to track remote branch refs/remotes/rack_remote/master.Switched to a new branch "rack_branch"$ lsAUTHORS KNOWN-ISSUES Rakefile contrib libCOPYING README bin example test

Page 266: Smacking Git Around   Advanced Git Tricks

C1

C0

master

C2

C4

rack_branch

C5

C6

C3

rack_remote/master

Page 267: Smacking Git Around   Advanced Git Tricks

$ git checkout master$ lsREADME rack_app.rb $ git checkout rack_branch$ lsAUTHORS KNOWN-ISSUESRakefile contrib libCOPYING README bin example test

Page 268: Smacking Git Around   Advanced Git Tricks

$ git checkout master$ lsREADME rack_app.rb $ git checkout rack_branch$ lsAUTHORS KNOWN-ISSUESRakefile contrib libCOPYING README bin example test

Page 269: Smacking Git Around   Advanced Git Tricks

$ git checkout master$ lsREADME rack_app.rb $ git checkout rack_branch$ lsAUTHORS KNOWN-ISSUESRakefile contrib libCOPYING README bin example test

Page 270: Smacking Git Around   Advanced Git Tricks

$ git checkout master$ lsREADME rack_app.rb $ git checkout rack_branch$ lsAUTHORS KNOWN-ISSUESRakefile contrib libCOPYING README bin example test

Page 271: Smacking Git Around   Advanced Git Tricks

checkout ‘rack’ into my project

Page 272: Smacking Git Around   Advanced Git Tricks

$ git read-tree --prefix=rack/ -u rack_branch$ lsREADME rack rack_app.rb$ ls rackAUTHORS KNOWN-ISSUESRakefilecontrib libCOPYING README bin example test$ git add rack$ git commit -m 'added rack code'[master 0839fd8] added rack code 108 files changed, 10334 insertions(+), 0 deletions(-) create mode 100644 rack/AUTHORS create mode 100644 rack/COPYING ... create mode 100644 rack/test/testrequest.rb

Page 273: Smacking Git Around   Advanced Git Tricks

$ git read-tree --prefix=rack/ -u rack_branch$ lsREADME rack rack_app.rb$ ls rackAUTHORS KNOWN-ISSUESRakefilecontrib libCOPYING README bin example test$ git add rack$ git commit -m 'added rack code'[master 0839fd8] added rack code 108 files changed, 10334 insertions(+), 0 deletions(-) create mode 100644 rack/AUTHORS create mode 100644 rack/COPYING ... create mode 100644 rack/test/testrequest.rb

Page 274: Smacking Git Around   Advanced Git Tricks

$ git read-tree --prefix=rack/ -u rack_branch$ lsREADME rack rack_app.rb$ ls rackAUTHORS KNOWN-ISSUESRakefilecontrib libCOPYING README bin example test$ git add rack$ git commit -m 'added rack code'[master 0839fd8] added rack code 108 files changed, 10334 insertions(+), 0 deletions(-) create mode 100644 rack/AUTHORS create mode 100644 rack/COPYING ... create mode 100644 rack/test/testrequest.rb

Page 275: Smacking Git Around   Advanced Git Tricks

$ git read-tree --prefix=rack/ -u rack_branch$ lsREADME rack rack_app.rb$ ls rackAUTHORS KNOWN-ISSUESRakefilecontrib libCOPYING README bin example test$ git add rack$ git commit -m 'added rack code'[master 0839fd8] added rack code 108 files changed, 10334 insertions(+), 0 deletions(-) create mode 100644 rack/AUTHORS create mode 100644 rack/COPYING ... create mode 100644 rack/test/testrequest.rb

Page 276: Smacking Git Around   Advanced Git Tricks

$ git read-tree --prefix=rack/ -u rack_branch$ lsREADME rack rack_app.rb$ ls rackAUTHORS KNOWN-ISSUESRakefilecontrib libCOPYING README bin example test$ git add rack$ git commit -m 'added rack code'[master 0839fd8] added rack code 108 files changed, 10334 insertions(+), 0 deletions(-) create mode 100644 rack/AUTHORS create mode 100644 rack/COPYING ... create mode 100644 rack/test/testrequest.rb

Page 277: Smacking Git Around   Advanced Git Tricks

$ git read-tree --prefix=rack/ -u rack_branch$ lsREADME rack rack_app.rb$ ls rackAUTHORS KNOWN-ISSUESRakefilecontrib libCOPYING README bin example test$ git add rack$ git commit -m 'added rack code'[master 0839fd8] added rack code 108 files changed, 10334 insertions(+), 0 deletions(-) create mode 100644 rack/AUTHORS create mode 100644 rack/COPYING ... create mode 100644 rack/test/testrequest.rb

Page 278: Smacking Git Around   Advanced Git Tricks

edit a file in rack

Page 279: Smacking Git Around   Advanced Git Tricks

$ vim rack/lib/rack.rb $ git commit -am 'added awesome to rack'[master b1b77ee] added awesome to rack 1 files changed, 1 insertions(+), 0 deletions(-)$ git checkout rack_branch$ git merge --squash -s subtree --no-commit masterSquash commit -- not updating HEADAutomatic merge went well; stopped before committing as requested$ git status# On branch rack_branch# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: lib/rack.rb#

Page 280: Smacking Git Around   Advanced Git Tricks

$ vim rack/lib/rack.rb $ git commit -am 'added awesome to rack'[master b1b77ee] added awesome to rack 1 files changed, 1 insertions(+), 0 deletions(-)$ git checkout rack_branch$ git merge --squash -s subtree --no-commit masterSquash commit -- not updating HEADAutomatic merge went well; stopped before committing as requested$ git status# On branch rack_branch# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: lib/rack.rb#

Page 281: Smacking Git Around   Advanced Git Tricks

$ vim rack/lib/rack.rb $ git commit -am 'added awesome to rack'[master b1b77ee] added awesome to rack 1 files changed, 1 insertions(+), 0 deletions(-)$ git checkout rack_branch$ git merge --squash -s subtree --no-commit masterSquash commit -- not updating HEADAutomatic merge went well; stopped before committing as requested$ git status# On branch rack_branch# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: lib/rack.rb#

Page 282: Smacking Git Around   Advanced Git Tricks

submit the change back to rack

Page 283: Smacking Git Around   Advanced Git Tricks

$ vim rack/lib/rack.rb $ git commit -am 'added awesome to rack'[master b1b77ee] added awesome to rack 1 files changed, 1 insertions(+), 0 deletions(-)$ git checkout rack_branch$ git merge --squash -s subtree --no-commit masterSquash commit -- not updating HEADAutomatic merge went well; stopped before committing as requested$ git status# On branch rack_branch# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: lib/rack.rb#

Page 284: Smacking Git Around   Advanced Git Tricks

git merge -s subtree

Page 285: Smacking Git Around   Advanced Git Tricks

$ vim rack/lib/rack.rb $ git commit -am 'added awesome to rack'[master b1b77ee] added awesome to rack 1 files changed, 1 insertions(+), 0 deletions(-)$ git checkout rack_branch$ git merge -s subtree --no-commit --squash masterSquash commit -- not updating HEADAutomatic merge went well; stopped before committing as requested$ git status# On branch rack_branch# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: lib/rack.rb#

Page 286: Smacking Git Around   Advanced Git Tricks

$ vim rack/lib/rack.rb $ git commit -am 'added awesome to rack'[master b1b77ee] added awesome to rack 1 files changed, 1 insertions(+), 0 deletions(-)$ git checkout rack_branch$ git merge -s subtree --no-commit --squash masterSquash commit -- not updating HEADAutomatic merge went well; stopped before committing as requested$ git status# On branch rack_branch# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: lib/rack.rb#

Page 287: Smacking Git Around   Advanced Git Tricks

$ vim rack/lib/rack.rb $ git commit -am 'added awesome to rack'[master b1b77ee] added awesome to rack 1 files changed, 1 insertions(+), 0 deletions(-)$ git checkout rack_branch$ git merge -s subtree --no-commit --squash masterSquash commit -- not updating HEADAutomatic merge went well; stopped before committing as requested$ git status# On branch rack_branch# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: lib/rack.rb#

Page 288: Smacking Git Around   Advanced Git Tricks

$ vim rack/lib/rack.rb $ git commit -am 'added awesome to rack'[master b1b77ee] added awesome to rack 1 files changed, 1 insertions(+), 0 deletions(-)$ git checkout rack_branch$ git merge -s subtree --no-commit --squash masterSquash commit -- not updating HEADAutomatic merge went well; stopped before committing as requested$ git status# On branch rack_branch# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: lib/rack.rb#

Page 289: Smacking Git Around   Advanced Git Tricks

$ vim rack/lib/rack.rb $ git commit -am 'added awesome to rack'[master b1b77ee] added awesome to rack 1 files changed, 1 insertions(+), 0 deletions(-)$ git checkout rack_branch$ git merge -s subtree --no-commit --squash masterSquash commit -- not updating HEADAutomatic merge went well; stopped before committing as requested$ git status# On branch rack_branch# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: lib/rack.rb#

Page 290: Smacking Git Around   Advanced Git Tricks

$ vim rack/lib/rack.rb $ git commit -am 'added awesome to rack'[master b1b77ee] added awesome to rack 1 files changed, 1 insertions(+), 0 deletions(-)$ git checkout rack_branch$ git merge -s subtree --no-commit --squash masterSquash commit -- not updating HEADAutomatic merge went well; stopped before committing as requested$ git status# On branch rack_branch# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: lib/rack.rb#

Page 291: Smacking Git Around   Advanced Git Tricks

$ vim rack/lib/rack.rb $ git commit -am 'added awesome to rack'[master b1b77ee] added awesome to rack 1 files changed, 1 insertions(+), 0 deletions(-)$ git checkout rack_branch$ git merge -s subtree --no-commit --squash masterSquash commit -- not updating HEADAutomatic merge went well; stopped before committing as requested$ git status# On branch rack_branch# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: lib/rack.rb#

Page 292: Smacking Git Around   Advanced Git Tricks

$ vim rack/lib/rack.rb $ git commit -am 'added awesome to rack'[master b1b77ee] added awesome to rack 1 files changed, 1 insertions(+), 0 deletions(-)$ git checkout rack_branch$ git merge -s subtree --no-commit --squash masterSquash commit -- not updating HEADAutomatic merge went well; stopped before committing as requested$ git status# On branch rack_branch# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: lib/rack.rb#

Page 293: Smacking Git Around   Advanced Git Tricks

$ vim rack/lib/rack.rb $ git commit -am 'added awesome to rack'[master b1b77ee] added awesome to rack 1 files changed, 1 insertions(+), 0 deletions(-)$ git checkout rack_branch$ git merge -s subtree --no-commit --squash masterSquash commit -- not updating HEADAutomatic merge went well; stopped before committing as requested$ git status# On branch rack_branch# Changes to be committed:# (use "git reset HEAD <file>..." to unstage)## modified: lib/rack.rb#

Page 294: Smacking Git Around   Advanced Git Tricks

git merge -s subtree --no-commit --squash master

Page 295: Smacking Git Around   Advanced Git Tricks

git merge -s subtree --no-commit --squash master

really?

Page 296: Smacking Git Around   Advanced Git Tricks

http://dysinger.net/2008/04/29/replacing-braid-or-piston-for-git-with-40-lines-of-rake/

Tim Dysinger

Page 297: Smacking Git Around   Advanced Git Tricks

http://dysinger.net/2008/04/29/replacing-braid-or-piston-for-git-with-40-lines-of-rake/

http://tinyurl.com/braidgit

Tim Dysinger

Page 298: Smacking Git Around   Advanced Git Tricks

Patch Staging

Page 299: Smacking Git Around   Advanced Git Tricks

git add -p

Page 300: Smacking Git Around   Advanced Git Tricks

$ 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 301: Smacking Git Around   Advanced Git Tricks

$ 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 302: Smacking Git Around   Advanced Git Tricks

$ 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 303: Smacking Git Around   Advanced Git Tricks

$ 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 304: Smacking Git Around   Advanced Git Tricks

$ 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 305: Smacking Git Around   Advanced Git Tricks

$ 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 306: Smacking Git Around   Advanced Git Tricks

@@ -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 307: Smacking Git Around   Advanced Git Tricks

@@ -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 308: Smacking Git Around   Advanced Git Tricks

@@ -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 309: Smacking Git Around   Advanced Git Tricks

$ 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 310: Smacking Git Around   Advanced Git Tricks

$ 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 311: Smacking Git Around   Advanced Git Tricks

$ 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 312: Smacking Git Around   Advanced Git Tricks

$ 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 313: Smacking Git Around   Advanced Git Tricks

partially stage files

Page 314: Smacking Git Around   Advanced Git Tricks

git add -p

Page 315: Smacking Git Around   Advanced Git Tricks

Debugging

Page 316: Smacking Git Around   Advanced Git Tricks

Annotation

Page 317: Smacking Git Around   Advanced Git Tricks

git blame

Page 318: Smacking Git Around   Advanced Git Tricks

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

Page 319: Smacking Git Around   Advanced Git Tricks

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 320: Smacking Git Around   Advanced Git Tricks

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 321: Smacking Git Around   Advanced Git Tricks

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 322: Smacking Git Around   Advanced Git Tricks

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 323: Smacking Git Around   Advanced Git Tricks

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 324: Smacking Git Around   Advanced Git Tricks

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 325: Smacking Git Around   Advanced Git Tricks

git blame -C GITPackUpload.m

Page 326: Smacking Git Around   Advanced Git Tricks

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 327: Smacking Git Around   Advanced Git Tricks

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 328: Smacking Git Around   Advanced Git Tricks

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 329: Smacking Git Around   Advanced Git Tricks

Bisecting

Page 330: Smacking Git Around   Advanced Git Tricks

binary search for where a bug was introduced

Page 331: Smacking Git Around   Advanced Git Tricks

$ 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 332: Smacking Git Around   Advanced Git Tricks

$ 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 333: Smacking Git Around   Advanced Git Tricks

$ 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 334: Smacking Git Around   Advanced Git Tricks

$ 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 335: Smacking Git Around   Advanced Git Tricks

$ 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 336: Smacking Git Around   Advanced Git Tricks

$ 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 337: Smacking Git Around   Advanced Git Tricks

$ 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 338: Smacking Git Around   Advanced Git Tricks

$ 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 339: Smacking Git Around   Advanced Git Tricks

$ 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 340: Smacking Git Around   Advanced Git Tricks

$ 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 341: Smacking Git Around   Advanced Git Tricks

$ 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 342: Smacking Git Around   Advanced Git Tricks

$ git bisect reset

Page 343: Smacking Git Around   Advanced Git Tricks

Customizing

Page 344: Smacking Git Around   Advanced Git Tricks

Autocorrect

Page 345: Smacking Git Around   Advanced Git Tricks

$ git com git: 'com' is not a git-command. See 'git --help'.

Did you mean this? commit

Page 346: Smacking Git Around   Advanced Git Tricks

$ git com git: 'com' is not a git-command. See 'git --help'.

Did you mean this? commit

Page 347: Smacking Git Around   Advanced Git Tricks

help.autocorrect

Page 348: Smacking Git Around   Advanced Git Tricks

$ git config --global help.autocorrect 1

Page 349: Smacking Git Around   Advanced Git Tricks

$ git comWARNING: You called a Git program named 'com', which does not exist.Continuing under the assumption that you meant 'commit'

Page 350: Smacking Git Around   Advanced Git Tricks

Colors

Page 351: Smacking Git Around   Advanced Git Tricks

$ git config --global color.ui true

Page 352: Smacking Git Around   Advanced Git Tricks

Custom Merge Tool

Page 353: Smacking Git Around   Advanced Git Tricks

perforce visual merge tool

Page 354: Smacking Git Around   Advanced Git Tricks
Page 355: Smacking Git Around   Advanced Git Tricks

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

Page 356: Smacking Git Around   Advanced Git Tricks

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

Page 357: Smacking Git Around   Advanced Git Tricks

$ git config --global merge.tool extMerge

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

$ git config --global mergetool.trustExitCode = false

Page 358: Smacking Git Around   Advanced Git Tricks

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

~/.gitconfig

Page 359: Smacking Git Around   Advanced Git Tricks

git mergetool

Page 360: Smacking Git Around   Advanced Git Tricks

Git Attributes

Page 361: Smacking Git Around   Advanced Git Tricks

.gitattributes

Page 362: Smacking Git Around   Advanced Git Tricks

Diff Binary Files

Page 363: Smacking Git Around   Advanced Git Tricks

Images

Page 364: Smacking Git Around   Advanced Git Tricks

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

Page 365: Smacking Git Around   Advanced Git Tricks

tell Git how to diff a binary file

Page 366: Smacking Git Around   Advanced Git Tricks

exiftool

Page 367: Smacking Git Around   Advanced Git Tricks

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

Page 368: Smacking Git Around   Advanced Git Tricks

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

every file that ends in .png

Page 369: Smacking Git Around   Advanced Git Tricks

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

pre-process them with a strategy called ‘exif ’

Page 370: Smacking Git Around   Advanced Git Tricks

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

Page 371: Smacking Git Around   Advanced Git Tricks

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

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

Page 372: Smacking Git Around   Advanced Git Tricks

$ 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 373: Smacking Git Around   Advanced Git Tricks

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

Page 374: Smacking Git Around   Advanced Git Tricks

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 375: Smacking Git Around   Advanced Git Tricks

Documents

Page 376: Smacking Git Around   Advanced Git Tricks

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

Page 377: Smacking Git Around   Advanced Git Tricks

$ 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 378: Smacking Git Around   Advanced Git Tricks

$ 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 379: Smacking Git Around   Advanced Git Tricks

File Filtering

Page 380: Smacking Git Around   Advanced Git Tricks

Staging Area

fileA.txt

fileB.txt

fileC.rb

Page 381: Smacking Git Around   Advanced Git Tricks

clean

smudge

*.txt Filter

Staging Area

fileA.txt

fileB.txt

fileC.rb

clean

smudge

*.txt Filter

Page 382: Smacking Git Around   Advanced Git Tricks

clean

smudge

*.txt Filter

Staging Area

fileA.txt

fileB.txt

fileC.rb

git checkout

clean

smudge

*.txt Filter

Page 383: Smacking Git Around   Advanced Git Tricks

Staging Area Working Directory

fileA.txt

fileB.txt clean

smudge fileA.txt'

fileB.txt'

*.txt Filter

fileC.rb fileC.rb

git checkout

Page 384: Smacking Git Around   Advanced Git Tricks

Staging Area Working Directory

fileA.txt

fileB.txt clean

smudge fileA.txt'

fileB.txt'

*.txt Filter

fileC.rb fileC.rb

Page 385: Smacking Git Around   Advanced Git Tricks

Staging Area Working Directory

fileA.txt

fileB.txt clean

smudge fileA.txt'

fileB.txt'

*.txt Filter

fileC.rb fileC.rb

git commit

Page 386: Smacking Git Around   Advanced Git Tricks

Staging Area Working Directory

fileA.txt

fileB.txt clean

smudge fileA.txt'

fileB.txt'

*.txt Filter

fileC.rb fileC.rb

git commit

Staging Area Working Directory

fileA.txt

fileB.txt clean

smudge fileA.txt'

fileB.txt'

*.txt Filter

fileC.rb fileC.rb

Page 387: Smacking Git Around   Advanced Git Tricks

expanding a $Date$

Page 388: Smacking Git Around   Advanced Git Tricks

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

/usr/bin/expand_date

Page 389: Smacking Git Around   Advanced Git Tricks

git config filter.dater.smudge expand_date

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

Page 390: Smacking Git Around   Advanced Git Tricks

git config filter.dater.smudge expand_date

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

replace $Date(whatever)$ with $Date$

Page 391: Smacking Git Around   Advanced Git Tricks

git config filter.dater.smudge expand_date

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

replace $Date(whatever)$ with $Date$

Page 392: Smacking Git Around   Advanced Git Tricks

test it

Page 393: Smacking Git Around   Advanced Git Tricks

$ 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 394: Smacking Git Around   Advanced Git Tricks

$ 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 395: Smacking Git Around   Advanced Git Tricks

$ 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 396: Smacking Git Around   Advanced Git Tricks

$ 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 397: Smacking Git Around   Advanced Git Tricks

$ 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 398: Smacking Git Around   Advanced Git Tricks

$ 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 399: Smacking Git Around   Advanced Git Tricks

$ 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

Page 400: Smacking Git Around   Advanced Git Tricks

</tricks></tips>

Page 401: Smacking Git Around   Advanced Git Tricks

one more thing...

Page 402: Smacking Git Around   Advanced Git Tricks

2

Page 403: Smacking Git Around   Advanced Git Tricks
Page 404: Smacking Git Around   Advanced Git Tricks
Page 405: Smacking Git Around   Advanced Git Tricks

git server

hg client git clienthg client

Page 406: Smacking Git Around   Advanced Git Tricks

hg-git.github.com

Page 407: Smacking Git Around   Advanced Git Tricks
Page 408: Smacking Git Around   Advanced Git Tricks

http://bitbucket.org/Scotty/hg-git/

Page 409: Smacking Git Around   Advanced Git Tricks

http://github.com/schacon/hg-git

Page 410: Smacking Git Around   Advanced Git Tricks

$ hg gpush githubpushing to : githubexporting git objectsconverting revision 78creating and sending data github::refs/heads/master : f8cebef6 => ffbc960d

Page 411: Smacking Git Around   Advanced Git Tricks

beta

Page 412: Smacking Git Around   Advanced Git Tricks

• lossless conversion

• all pushes to GitHub for the project have been through Hg

• have pulled and merged changes introduced on GitHub via Hg

• have pulled and merged changes introduced on BitBucket and pushed back to GitHub

Page 413: Smacking Git Around   Advanced Git Tricks

hg-git.github.com

Page 414: Smacking Git Around   Advanced Git Tricks

fin

Page 415: Smacking Git Around   Advanced Git Tricks

Resourcesgit-scm.com

gitcasts.com

learn.github.com

#git / #github on IRC

peepcode - git book and screencast

[email protected]

me, in person, tonight, someplace that serves whiskey