Академический Документы
Профессиональный Документы
Культура Документы
by Scott Chacon
Me
Scott Chacon
github.com/schacon
“Scott Chacon has an
understandable but borderline
unhealthy obsession with Git”
- Ilya Grigorik
igvita.com
git-scm.com
book.git-scm.com
schacon@gmail.com
</me>
previously, on Git...
GIT
Git
image by matthew mccullough
Scott Chacon
Scott Scott Chacon
is a Git
v1 v2 v3
98ca9.. 34ac2.. f30ab..
commit size commit size commit size
tree 0de24 tree 184ca tree 92ec2
author Scott parent 98ca9 parent 34ac2
committer Scott author Scott author Scott
initial commit of my project committer Scott committer Scott
fixed bug #1328 - stack add feature #32 - ability to
overflow under certain add new formats to the central
10af9.. bc52a..
b70f8..
0ad1a..
tree size
blob size
blob 0ad1a tricks.rb
require 'grit/git-ruby/reposi
require 'grit/git-ruby/file_i
module Grit
module Tricks
98ca9..
e8455..
commit size
0de24..
0de24.. blob size
tree 0de24
== LICENSE:
parent nil tree size
(The MIT License)
author Scott blob e8455 README Copyright (c) 2007 Tom Preston-
committer Scott
tree 10af9 lib Permission is hereby granted, f
my commit message goes here ree of charge, to any person ob
and it is really, really cool
10af9.. bc52a..
b70f8..
0ad1a..
tree size
blob size
blob 0ad1a tricks.rb
require 'grit/git-ruby/reposi
require 'grit/git-ruby/file_i
module Grit
module Tricks
0de24..
22d8858e8513666bf91b82bd2939ec7b0d1974da
stable master
a23fe 3acd1
topic
stable master
a23fe 3acd1
topic
stable master
a23fe 3acd1
topic
stable master
a23fe 3acd1
topic
$ time git checkout -b newbranch
Switched to a new branch "newbranch"
real 0m0.040s
user 0m0.003s
sys 0m0.008s
$ time git checkout -b newbranch
Switched to a new branch "newbranch"
real 0m0.040s
user 0m0.003s
sys 0m0.008s
master
develop
topic
distributed
development
Data Munging
Debugging
Customizing
Selection and Ranges
Revision Selection
Revision Selection
alternate ways to refer to
objects or ranges of objects
Revision Selection
full sha-1
partial sha-1
branch or tag name
caret parent
tilde spec
blob spec
relative specs
ranges
Full SHA1
6e453f523fa1da50ecb04431101112b3611c6a4d
Partial SHA1
6e453f523fa1da50ecb04431101112b3611c6a4d
6e453f523fa1da50
6e453
Branch, Remote
or Tag Name
v1.0
default
m/cupcake
Caret Parent
default^2
jess/master master
master^
b3be1 a09c6 df2fa c36ae
jess/master master
master^2
b3be1 a09c6 df2fa c36ae
jess/master master
Tilde Spec
default~2
grandparent of ‘default’
(parent of the parent)
master~2
b3be1 a09c6 df2fa c36ae
jess/master master
master^^^2
master~2^2
b3be1 a09c6 df2fa c36ae
jess/master master
master^^^2
master~2^2
b3be1 a09c6 df2fa c36ae
jess/master master
master^^^2
master~2^2
b3be1 a09c6 df2fa c36ae
jess/master master
Blob Spec
default:path/to/file
master@{yesterday}
master@{5}
ce0e4..e4272
[old]..[new]
ce0e4..
jess/master master
jess/master..master
b3be1 a09c6 df2fa c36ae
jess/master master
jess/master..master
b3be1 a09c6 df2fa c36ae
jess/master master
jess/master..master
b3be1 a09c6 df2fa c36ae
jess/master master
jess/master..master
b3be1 a09c6 df2fa c36ae
jess/master master
jess/master..master
b3be1 a09c6 df2fa c36ae
jess/master master
jess/master..master
b3be1 a09c6 df2fa c36ae
jess/master master
jess/master..master
b3be1 a09c6 df2fa c36ae
jess/master master
jess/master..c36ae
b3be1 a09c6 df2fa c36ae
jess/master master
jess/master..c36ae
b3be1 a09c6 df2fa c36ae
jess/master master
jess/master..c36ae
b3be1 a09c6 df2fa c36ae
jess/master master
jess/master..c36ae
b3be1 a09c6 df2fa c36ae
jess/master master
Advanced Log
Log Subsets
what am I going to
push?
git log origin/master..
origin/master C1 master HEAD
C0
C4 master HEAD
C3
C2
origin/master C1
C0
origin/master C7 C4 master HEAD
C6 C3
C5 C2
C1
C6 C3
C5 C2
C1
C6 C3
C5 C2
C1
git log
origin/master..HEAD
C0
origin/master C7 C4 master HEAD
C6 C3
C5 C2
C1
git log
origin/master..HEAD
C0
origin/master C7 C4 master HEAD
C6 C3
C5 C2
C1
git log
origin/master..HEAD
C0
origin/master C7 C4 master HEAD
C6 C3
C5 C2
C1
git log
origin/master..HEAD
C0
commit 72d404debaa804fca82fd9cf710fbde48c7305c6
Author: Shawn O. Pearce <spearce@spearce.org>
Date: Sun Oct 12 13:13:59 2008 -0700
commit 969c877506cf8cc760c7b251fef6c5b6850bfc19
Author: Jeff King <peff@peff.net>
Date: Sun Oct 12 00:06:11 2008 -0400
commit ff74126c03a8dfd04e7533573a5c420f2a7112ac
Author: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Date: Fri Oct 10 13:42:12 2008 +0200
commit 969c877506cf8cc760c7b251fef6c5b6850bfc19
C3 Author: Jeff King <peff@peff.net>
Date: Sun Oct 12 00:06:11 2008 -0400
commit ff74126c03a8dfd04e7533573a5c420f2a7112ac
C2 Author: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Date: Fri Oct 10 13:42:12 2008 +0200
C6 C3
C5 C2
C1
git log
origin/master .. HEAD
C0
origin/master C7 C4 master HEAD
C6 C3
C5 C2
C1
git log
HEAD .. origin/master
C0
origin/master C7 C4 master HEAD
C6 C3
C5 C2
C1
git log
HEAD .. origin/master
C0
“commits in origin/master
not in HEAD”
git log origin/master..
C1
C0
master
C3
origin/master
C1
C0
experiment
C10
C9
C8
master
C3
origin/master
C1
C0
experiment
C10
master
origin/master
C7 C5 C9
C6 C4 C8
C2 C3
C1
C0
which changes aren’t in
experiment?
git log origin/master master ^experiment
experiment
C10
master
origin/master
C7 C5 C9
C6 C4 C8
C2 C3
C1
C0
git log origin/master master ^experiment
experiment
C10
master
origin/master
C7 C5 C9
C6 C4 C8
C2 C3
C1
C0
git log origin/master master ^experiment
experiment
C10
master
origin/master
C7 C5 C9
C6 C4 C8
C2 C3
C1
C0
git log origin/master master ^experiment
experiment
C10
master
origin/master
C7 C5 C9
C6 C4 C8
C2 C3
C1
C0
git log origin/master master ^experiment
experiment
C10
master
origin/master
C7 C5 C9
C6 C4 C8
C2 C3
C1
C0
git log origin/master master ^experiment
experiment
C10
master
origin/master
C7 C5 C9
C6 C4 C8
C2 C3
C1
C0
git log origin/master master ^experiment
experiment
C10
master
origin/master
C7 C5 C9
C6 C4 C8
C2 C3
C1
C0
git log --graph
git log --pretty=oneline --graph
gitk
gitk 6d13f..41aba
Revision Diffs
git diff revA revB
$ echo ‘version one’ > test
$ git add test
$ git commit -m ‘C1’
master
C1
$ git checkout -b topic
$ echo ‘version two’ >> test
$ git commit -m ‘C2’
topic
C2
master
C1
$ echo ‘version three’ >> test
$ git commit -m ‘C3’
topic
C3
C2
master
C1
$ git checkout master
$ echo ‘version four’ >> test
$ git commit -m ‘C4’
topic
C3
master
C4 C2
C1
$ echo ‘version five’ >> test
$ git commit -m ‘C5’
master topic
C5 C3
C4 C2
C1
master topic
C5 C3
$ git diff topic
C4 C2
C1
master topic
C1
master topic
C1
master topic
C1
$ git diff topic
diff --git a/test b/test
master topic
index 304313d..bd8c6c9 100644
--- a/test
+++ b/test
C5 C3 @@ -1,3 +1,3 @@
version one
-version two
-version three
C4 C2 +version four
+version five
C1
$ git diff topic
diff --git a/test b/test
master topic
index 304313d..bd8c6c9 100644
--- a/test
+++ b/test
C5 C3 @@ -1,3 +1,3 @@
version one
-version two
-version three
C4 C2 +version four
+version five
C1
$ git diff HEAD topic
diff --git a/test b/test
master topic
index bd8c6c9..304313d 100644
--- a/test
+++ b/test
C5 C3 @@ -1,3 +1,3 @@
version one
-version four
-version five
C4 C2 +version two
+version three
C1
$ git diff HEAD topic
diff --git a/test b/test
master topic
index bd8c6c9..304313d 100644
--- a/test
+++ b/test
C5 C3 @@ -1,3 +1,3 @@
version one
-version four
-version five
C4 C2 +version two
+version three
C1
git diff HEAD topic
git diff HEAD...topic
git diff HEAD...topic
$ git diff HEAD topic
master topic
C5 C3
C4 C2
C1
$ git diff HEAD topic
master topic
C5 C3
C4 C2
C1
$ git diff HEAD...topic
master topic
C5 C3
C4 C2
C1
$ git diff HEAD...topic
diff --git a/test b/test
master topic index 9bc69cf..304313d 100644
--- a/test
+++ b/test
C5 C3 @@ -1 +1,3 @@
version one
+version two
+version three
C4 C2
C1
$ git diff HEAD...topic
diff --git a/test b/test
master topic index 9bc69cf..304313d 100644
--- a/test
what would happen if I
+++ b/test
C5 C3 @@ -1 +1,3 @@
merged in topic?
version one
+version two
+version three
C4 C2
C1
Data Munging
Rewriting History
Modifying the last commit
git commit --amend
Rebasing
master topic
C5 C3
C4 C2
C1
topic
master C6
C5 C3
C4 C2
C1
C5 C3
C4 C2
C1
C5 C3
C4 C2
C1
C5 C3
C4 C2
C1
C5 C3
C4 C2
C1
C4 C2
C1
C5 C3
C4 C2
C1
2-3.patch
master topic
C5 C3
C4 C2
C1
git diff c1 c2 > 1-2.patch
2-3.patch
master topic
C5 C3
C4 C2
C1
git diff c1 c2 > 1-2.patch
1-2.patch
2-3.patch
master topic
C5 C3
C4 C2
C1
1-2.patch
2-3.patch
git rebase master
master topic
C5 C3
C4 C2
C1
1-2.patch
2-3.patch
git rebase master
1-2.patch
master topic
C5 C3
C4 C2
C1
2-3.patch
git rebase master
topic
master
C2'
C5 C3
C4 C2
C1
2-3.patch
git rebase master
2-3.patch
topic
master
C2'
C5 C3
C4 C2
C1
topic
git rebase master
C3'
master
C2'
C5 C3
C4 C2
C1
topic
C3'
master
C2'
C4 C2
C1
topic
C3'
master
C2'
C4 C2
C1
topic
C3'
C2'
C4
C1
Fun with Rebasing
rebase --onto
Transplanting Topic
Branches
master
C1 C2
master
C1 C2
C3
server
master
C1 C2
C3
server
C8 C9
client
master
C1 C2
C3 C4 C10
server
C8 C9
client
master
C1 C2 C5 C6
C3 C4 C10
server
C8 C9
client
move your ‘client’
branch work to your
‘master’ branch
master
C1 C2 C5 C6
C3 C4 C10
server
C8 C9
client
master
C1 C2 C5 C6
C3 C4 C10
server
C8 C9
client
master
C1 C2 C5 C6
C3 C4 C10
server
C8 C9
client
git rebase master
master
C1 C2 C5 C6
C3 C4 C10
server
C8 C9
client
git rebase master
master
C1 C2 C5 C6
C3 C4 C10
server
C8 C9
client
git rebase master
master
C1 C2 C5 C6
C3 C4 C10
server
C8 C9
client
git rebase master
master
C1 C2 C5 C6
C3 C4 C10
server
C8 C9
client
git rebase server
master
C1 C2 C5 C6
C3 C4 C10
server
C8 C9
client
git rebase server
master
C1 C2 C5 C6
C3 C4 C10
server
C8 C9
client
git rebase server
master
C1 C2 C5 C6
C3 C4 C10
server
C8 C9
client
git rebase server
master
C1 C2 C5 C6
C3 C4 C10
server
C8 C9
client
C1 C2 C5 C6
C3 C4 C10
server
C8 C9
client
C1 C2 C5 C6
C3 C4 C10
server
C8 C9
client
C1 C2 C5 C6
C3 C4 C10
server
C8 C9
client
C1
C1 C2 C5 C6
C6 C8'
C8 C9'
C9
C3 C4
C4 C10
C10
server
server
C8
C8 C9
C9
client
master client
C1 C2 C5 C6 C8' C9'
C3 C4 C10
server
C8 C9
master client
C1 C2 C5 C6 C8' C9'
C3 C4 C10
server
C8 C9
C1 C2 C5 C6 C8' C9'
C3 C4 C10
server
C8 C9
C1 C2 C5 C6 C8' C9'
C3 C4 C10
server
C8 C9
C1 C2 C5 C6
C6 C8' C9'
C3'
C3 C4'
C4 C10'
C10
server
C8 C9
C1
C1 C2
C2 C5
C5 C6
C6 C8'
C8' C9'
C9' C3'
C3' C4' C10'
C0 C1 C2
C3 C4 C5
topic
master
C0 C1 C2
C3 C4 C5
topic
master
C0 C1 C2
C3 C4 C5
topic
C0 C1 C2
C3 C4 C5
newtopic topic
C0 C1 C2
C3 C4 C5
newtopic topic
C0 C1 C2 C4' C5'
C3 C4 C5
newtopic
C4
C3
C2
C1
C0
default
C4
C3
C2
C1
C0
default
C4
C3
default~2 C2
C1
C0
default
C4
C3
default~2 C2
C1
C0
git rebase -i default~2^
git rebase -i default~2^
git rebase -i default~2^
pick 969c877 git apply --directory broken for new files
pick b75271d git diff <tree>{3,}: do not reverse order of args
pick 72d404d test-lib: fix broken printf
$_
$ git rebase -i default~2^
Stopped at 969c877... git apply --directory broken for new files
You can amend the commit now, with
$_
edit files
git add
git commit --amend
git rebase --continue
$ git rebase -i default~2^
Stopped at 969c877... git apply --directory broken for new files
You can amend the commit now, with
$_
edit files
git add
git commit --amend
git rebase --continue
$ git rebase -i default~2^
Stopped at 969c877... git apply --directory broken for new files
You can amend the commit now, with
$_
edit files
git add
git commit --amend
git rebase --continue
$ git rebase -i default~2^
Stopped at 969c877... git apply --directory broken for new files
You can amend the commit now, with
$_
edit files
git add
git commit --amend
git rebase --continue
default
C4 C4'
C3 C3'
C2 C2'
C1
C0
default
C4 C4'
C3 C3'
C2 C2'
C1
C0
default
C4 C4'
C3 C3'
C2 C2'
C1
C0
Squashing commits
together
pick 969c877 git apply --directory broken for new files
pick b75271d git diff <tree>{3,}: do not reverse order of args
pick 72d404d 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 <peff@peff.net>
#
# 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
# This is a combination of 3 commits.
# The first commit's message is:
git apply --directory broken for new files
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Author: Jeff King <peff@peff.net>
#
# 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
# This is a combination of 3 commits.
# The first commit's message is:
git apply --directory broken for new files
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Author: Jeff King <peff@peff.net>
#
# 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
# This is a combination of 3 commits.
# The first commit's message is:
git apply --directory broken for new files
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Author: Jeff King <peff@peff.net>
#
# 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
C4
C3
default
C2 C5
C1
C0
The Perils
scott jessica
default
C1
C0
scott jessica
default
C4
C3
default scott/default C2
C1 C1
C0 C0
scott jessica
C7 C7 C4
C6 C6
C3
C5 C5
C2
C1 C1
C0 C0
scott jessica
default
scott/default C8
default
C7 C7 C4
C6 C6
C3
C5 C5
C2
C1 C1
C0 C0
scott jessica
default
scott/default C8
default
C7 C7' C7 C4
C6 C6' C6
C3
C5 C5' C5
C2
C1 C1
C0 C0
scott jessica
default
C8
scott/default
default
C7 C7' C7' C7 C4
C6 C6' C6' C6
C3
C5 C5' C5' C5
C2
C1 C1
C0 C0
scott jessica
default
C9
scott/default C8
default
C7 C7' C7' C7 C4
C6 C6' C6' C6
C3
C5 C5' C5' C5
C2
C1 C1
C0 C0
Filter Branch
History Revision on Steroids
remove all instances of a
file from every commit
git filter-branch
--tree-filter 'rm -f filename'
HEAD
change your email
in all commits
git filter-branch --env-filter
"export GIT_AUTHOR_EMAIL=you@email.com"
HEAD
git filter-branch --env-filter
"export GIT_AUTHOR_EMAIL=you@email.com"
origin/master..HEAD
Subtree Merging
Alternative to
Submodules
$ ls
README rack_app.rb
$ git remote add rack_remote git@github.com:schacon/rack.git
$ git fetch rack_remote
warning: no common commits
remote: 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, do
Resolving deltas: 100% (1952/1952), done.
From git@github.com:schacon/rack
* [new branch] master -> rack_remote/master
$ git checkout -b rack_branch rack_remote/master
Branch rack_branch set up to track remote branch refs/remotes
Switched to a new branch "rack_branch"
$ ls
AUTHORS KNOWN-ISSUES Rakefile contrib lib
COPYING README bin example test
master
C3
C2
C1
C0
$ ls
README rack_app.rb
$ git remote add rack_remote git@github.com:schacon/rack.git
$ git fetch rack_remote
warning: no common commits
remote: 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, do
Resolving deltas: 100% (1952/1952), done.
From git@github.com:schacon/rack
* [new branch] master -> rack_remote/master
$ git checkout -b rack_branch rack_remote/master
Branch rack_branch set up to track remote branch refs/remotes
Switched to a new branch "rack_branch"
$ ls
AUTHORS KNOWN-ISSUES Rakefile contrib lib
COPYING README bin example test
$ ls
README rack_app.rb
$ git remote add rack_remote git@github.com:schacon/rack.git
$ git fetch rack_remote
warning: no common commits
remote: 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, do
Resolving deltas: 100% (1952/1952), done.
From git@github.com:schacon/rack
* [new branch] master -> rack_remote/master
$ git checkout -b rack_branch rack_remote/master
Branch rack_branch set up to track remote branch refs/remotes
Switched to a new branch "rack_branch"
$ ls
AUTHORS KNOWN-ISSUES Rakefile contrib lib
COPYING README bin example test
$ ls
README rack_app.rb
$ git remote add rack_remote git@github.com:schacon/rack.git
$ git fetch rack_remote
warning: no common commits
remote: 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, do
Resolving deltas: 100% (1952/1952), done.
From git@github.com:schacon/rack
* [new branch] master -> rack_remote/master
$ git checkout -b rack_branch rack_remote/master
Branch rack_branch set up to track remote branch refs/remotes
Switched to a new branch "rack_branch"
$ ls
AUTHORS KNOWN-ISSUES Rakefile contrib lib
COPYING README bin example test
$ ls
README rack_app.rb
$ git remote add rack_remote git@github.com:schacon/rack.git
$ git fetch rack_remote
warning: no common commits
remote: 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, do
Resolving deltas: 100% (1952/1952), done.
From git@github.com:schacon/rack
* [new branch] master -> rack_remote/master
$ git checkout -b rack_branch rack_remote/master
Branch rack_branch set up to track remote branch refs/remotes
Switched to a new branch "rack_branch"
$ ls
AUTHORS KNOWN-ISSUES Rakefile contrib lib
COPYING README bin example test
$ ls
README rack_app.rb
$ git remote add rack_remote git@github.com:schacon/rack.git
$ git fetch rack_remote
warning: no common commits
remote: 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, do
Resolving deltas: 100% (1952/1952), done.
From git@github.com:schacon/rack
* [new branch] master -> rack_remote/master
$ git checkout -b rack_branch rack_remote/master
Branch rack_branch set up to track remote branch refs/remotes
Switched to a new branch "rack_branch"
$ ls
AUTHORS KNOWN-ISSUES Rakefile contrib lib
COPYING README bin example test
$ ls
README rack_app.rb
$ git remote add rack_remote git@github.com:schacon/rack.git
$ git fetch rack_remote
warning: no common commits
remote: 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, do
Resolving deltas: 100% (1952/1952), done.
From git@github.com:schacon/rack
* [new branch] master -> rack_remote/master
$ git checkout -b rack_branch rack_remote/master
Branch rack_branch set up to track remote branch refs/remotes
Switched to a new branch "rack_branch"
$ ls
AUTHORS KNOWN-ISSUES Rakefile contrib lib
COPYING README bin example test
$ ls
README rack_app.rb
$ git remote add rack_remote git@github.com:schacon/rack.git
$ git fetch rack_remote
warning: no common commits
remote: 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, do
Resolving deltas: 100% (1952/1952), done.
From git@github.com:schacon/rack
* [new branch] master -> rack_remote/master
$ git checkout -b rack_branch rack_remote/master
Branch rack_branch set up to track remote branch refs/remotes
Switched to a new branch "rack_branch"
$ ls
AUTHORS KNOWN-ISSUES Rakefile contrib lib
COPYING README bin example test
$ ls
README rack_app.rb
$ git remote add rack_remote git@github.com:schacon/rack.git
$ git fetch rack_remote
warning: no common commits
remote: 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, do
Resolving deltas: 100% (1952/1952), done.
From git@github.com:schacon/rack
* [new branch] master -> rack_remote/master
$ git checkout -b rack_branch rack_remote/master
Branch rack_branch set up to track remote branch refs/remotes
Switched to a new branch "rack_branch"
$ ls
AUTHORS KNOWN-ISSUES Rakefile contrib lib
COPYING README bin example test
master
C3 rack_branch
C2 C6 rack_remote/master
C1 C5
C0 C4
$ git checkout master
$ ls
README rack_app.rb
$ git checkout rack_branch
$ ls
AUTHORS KNOWN-ISSUES Rakefile contrib lib
COPYING README bin example test
$ git checkout master
$ ls
README rack_app.rb
$ git checkout rack_branch
$ ls
AUTHORS KNOWN-ISSUES Rakefile contrib lib
COPYING README bin example test
$ git checkout master
$ ls
README rack_app.rb
$ git checkout rack_branch
$ ls
AUTHORS KNOWN-ISSUES Rakefile contrib lib
COPYING README bin example test
$ git checkout master
$ ls
README rack_app.rb
$ git checkout rack_branch
$ ls
AUTHORS KNOWN-ISSUES Rakefile contrib lib
COPYING README bin example test
checkout ‘rack’
into my project
$ git read-tree --prefix=rack/ -u rack_branch
$ ls
README rack rack_app.rb
$ ls rack
AUTHORS KNOWN-ISSUES Rakefile contrib lib
COPYING README bin example test
$ git add rack
$ git commit -m 'added rack code'
[master 0839fd8] added rack code
108 files changed, 10334 insertions(+), 0 dele
create mode 100644 rack/AUTHORS
create mode 100644 rack/COPYING
...
create mode 100644 rack/test/testrequest.rb
$ git read-tree --prefix=rack/ -u rack_branch
$ ls
README rack rack_app.rb
$ ls rack
AUTHORS KNOWN-ISSUES Rakefile contrib lib
COPYING README bin example test
$ git add rack
$ git commit -m 'added rack code'
[master 0839fd8] added rack code
108 files changed, 10334 insertions(+), 0 dele
create mode 100644 rack/AUTHORS
create mode 100644 rack/COPYING
...
create mode 100644 rack/test/testrequest.rb
$ git read-tree --prefix=rack/ -u rack_branch
$ ls
README rack rack_app.rb
$ ls rack
AUTHORS KNOWN-ISSUES Rakefile contrib lib
COPYING README bin example test
$ git add rack
$ git commit -m 'added rack code'
[master 0839fd8] added rack code
108 files changed, 10334 insertions(+), 0 dele
create mode 100644 rack/AUTHORS
create mode 100644 rack/COPYING
...
create mode 100644 rack/test/testrequest.rb
$ git read-tree --prefix=rack/ -u rack_branch
$ ls
README rack rack_app.rb
$ ls rack
AUTHORS KNOWN-ISSUES Rakefile contrib lib
COPYING README bin example test
$ git add rack
$ git commit -m 'added rack code'
[master 0839fd8] added rack code
108 files changed, 10334 insertions(+), 0 dele
create mode 100644 rack/AUTHORS
create mode 100644 rack/COPYING
...
create mode 100644 rack/test/testrequest.rb
$ git read-tree --prefix=rack/ -u rack_branch
$ ls
README rack rack_app.rb
$ ls rack
AUTHORS KNOWN-ISSUES Rakefile contrib lib
COPYING README bin example test
$ git add rack
$ git commit -m 'added rack code'
[master 0839fd8] added rack code
108 files changed, 10334 insertions(+), 0 dele
create mode 100644 rack/AUTHORS
create mode 100644 rack/COPYING
...
create mode 100644 rack/test/testrequest.rb
$ git read-tree --prefix=rack/ -u rack_branch
$ ls
README rack rack_app.rb
$ ls rack
AUTHORS KNOWN-ISSUES Rakefile contrib lib
COPYING README bin example test
$ git add rack
$ git commit -m 'added rack code'
[master 0839fd8] added rack code
108 files changed, 10334 insertions(+), 0 dele
create mode 100644 rack/AUTHORS
create mode 100644 rack/COPYING
...
create mode 100644 rack/test/testrequest.rb
edit a file in rack
$ 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 master
Squash commit -- not updating HEAD
Automatic merge went well; stopped before committin
$ git status
# On branch rack_branch
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: lib/rack.rb
#
$ 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 master
Squash commit -- not updating HEAD
Automatic merge went well; stopped before committin
$ git status
# On branch rack_branch
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: lib/rack.rb
#
$ 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 master
Squash commit -- not updating HEAD
Automatic merge went well; stopped before committin
$ git status
# On branch rack_branch
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: lib/rack.rb
#
submit the change
back to rack
$ 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 master
Squash commit -- not updating HEAD
Automatic merge went well; stopped before committin
$ git status
# On branch rack_branch
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: lib/rack.rb
#
git merge -s subtree
$ 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 master
Squash commit -- not updating HEAD
Automatic merge went well; stopped before committin
$ git status
# On branch rack_branch
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: lib/rack.rb
#
$ 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 master
Squash commit -- not updating HEAD
Automatic merge went well; stopped before committin
$ git status
# On branch rack_branch
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: lib/rack.rb
#
$ 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 master
Squash commit -- not updating HEAD
Automatic merge went well; stopped before committin
$ git status
# On branch rack_branch
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: lib/rack.rb
#
$ 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 master
Squash commit -- not updating HEAD
Automatic merge went well; stopped before committin
$ git status
# On branch rack_branch
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: lib/rack.rb
#
$ 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 master
Squash commit -- not updating HEAD
Automatic merge went well; stopped before committin
$ git status
# On branch rack_branch
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: lib/rack.rb
#
$ 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 master
Squash commit -- not updating HEAD
Automatic merge went well; stopped before committin
$ git status
# On branch rack_branch
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: lib/rack.rb
#
$ 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 master
Squash commit -- not updating HEAD
Automatic merge went well; stopped before committin
$ git status
# On branch rack_branch
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: lib/rack.rb
#
$ 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 master
Squash commit -- not updating HEAD
Automatic merge went well; stopped before committin
$ git status
# On branch rack_branch
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: lib/rack.rb
#
$ 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 master
Squash commit -- not updating HEAD
Automatic merge went well; stopped before committin
$ git status
# On branch rack_branch
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: lib/rack.rb
#
git merge -s subtree --no-commit --squash master
git merge -s subtree --no-commit --squash master
really?
Tim Dysinger
http://dysinger.net/2008/04/29/
replacing-braid-or-piston-for-git-with-40-lines-of-rake/
Tim Dysinger
http://dysinger.net/2008/04/29/
replacing-braid-or-piston-for-git-with-40-lines-of-rake/
http://tinyurl.com/braidgit
Patch Staging
git add -p
$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what wi
# (use "git checkout -- <file>..." to discar
#
# modified: ticgit.gemspec
#
no changes added to commit (use "git add" and/
$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what wi
# (use "git checkout -- <file>..." to discar
#
# modified: ticgit.gemspec
#
no changes added to commit (use "git add" and/
$ git add -p
diff --git a/ticgit.gemspec b/ticgit.gemspec
index 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 = "schacon@gmail.com"
Stage this hunk [y,n,a,d,/,j,J,g,e,?]? y
$ git add -p
diff --git a/ticgit.gemspec b/ticgit.gemspec
index 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 = "schacon@gmail.com"
Stage this hunk [y,n,a,d,/,j,J,g,e,?]? y
$ git add -p
diff --git a/ticgit.gemspec b/ticgit.gemspec
index 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 = "schacon@gmail.com"
Stage this hunk [y,n,a,d,/,j,J,g,e,?]?
$ git add -p
diff --git a/ticgit.gemspec b/ticgit.gemspec
index 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 = "schacon@gmail.com"
Stage this hunk [y,n,a,d,/,j,J,g,e,?]? y
@@ -9,9 +9,10 @@ Gem::Specification.new do |s|
s.files = ["lib/ticgit/base.rb", "lib/ticgit/
"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.bindir = 'bin'
- s.executables << "ti"
- s.executables << "ticgitweb"
+ s.executables = ["ti", "ticgitweb"]
+ s.default_executable = %q{ti}
s.homepage = "http://github/schacon/ticgit"
s.bindir = 'bin'
- s.executables << "ti"
- s.executables << "ticgitweb"
+ s.executables = ["ti", "ticgitweb"]
+ s.default_executable = %q{ti}
s.homepage = "http://github/schacon/ticgit"
[merge]
tool = extMerge
[mergetool "extMerge"]
cmd = extMerge "$BASE" "$LOCAL" "$REMOTE" "$MERGED"
trustExitCode = false
git mergetool
Git Attributes
.gitattributes
Diff Binary Files
Images
diff --git a/image.png b/image.png
index 88839c4..4afcb7c 100644
Binary files a/image.png and b/image.png differ
tell Git how to diff a
binary file
exiftool
$ echo '*.png diff=exif' >> .gitattributes
$ git config diff.exif.textconv exiftool
$ echo '*.png diff=exif' >> .gitattributes
$ git config diff.exif.textconv exiftool
fileA.txt
fileB.txt
fileC.rb
Staging Area
*.txt Filter
fileA.txt smudge
fileB.txt clean
fileC.rb
Staging Area
*.txt Filter
fileA.txt smudge
fileB.txt clean
fileC.rb
git checkout
Staging Area Working Directory
*.txt Filter
fileC.rb fileC.rb
git checkout
Staging Area Working Directory
*.txt Filter
fileC.rb fileC.rb
Staging Area Working Directory
*.txt Filter
fileC.rb fileC.rb
git commit
Staging Area Working Directory
*.txt Filter
fileC.rb fileC.rb
git commit
expanding a $Date$
/usr/bin/expand_date
#! /usr/bin/env ruby
data = STDIN.read
date = `git log --pretty=format:"%ad" -1`
puts data.gsub('$Date$', '$Date: ' + date + '$')
git config filter.dater.smudge expand_date
$ cat date_test.rb
# $Date: Tue Apr 21 07:26:52 2009 -0700$
$ echo '# $Date$' > date_test.rb
$ echo 'date*.rb filter=dater' >> .gitattributes
$ cat date_test.rb
# $Date: Tue Apr 21 07:26:52 2009 -0700$
</tricks></tips>
one more thing...
2
git server