Skip to content

Instantly share code, notes, and snippets.

@bkempner
Created May 30, 2012 22:01
Show Gist options
  • Save bkempner/2839211 to your computer and use it in GitHub Desktop.
Save bkempner/2839211 to your computer and use it in GitHub Desktop.
cherry-pick behavior
Maurices-MacBook-Pro:Projects ben$ mkdir gitfoo
Maurices-MacBook-Pro:Projects ben$ cd gitfoo/
Maurices-MacBook-Pro:gitfoo ben$ g init
Initialized empty Git repository in /Users/ben/Projects/gitfoo/.git/
Maurices-MacBook-Pro:gitfoo ben$ touch foo
echMaurices-MacBook-Pro:gitfoo ben$ echo 'foo' >> foo
Maurices-MacBook-Pro:gitfoo ben$ g c -am 'initial commit'
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# foo
nothing added to commit but untracked files present (use "git add" to track)
Maurices-MacBook-Pro:gitfoo ben$ g a .
Maurices-MacBook-Pro:gitfoo ben$ g c -am 'initial commit'
[master (root-commit) 858db25] initial commit
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 foo
Maurices-MacBook-Pro:gitfoo ben$ g l
commit 858db259df9a40df840dfbd584e75b9a49936382
Author: Ben Kempner <ben@verticalbrands.com>
Date: Wed May 30 14:59:44 2012 -0700
initial commit
Maurices-MacBook-Pro:gitfoo ben$
Maurices-MacBook-Pro:gitfoo ben$ g co -b branch-1
Switched to a new branch 'branch-1'
Maurices-MacBook-Pro:gitfoo ben$ echo 'bar' >> foo
Maurices-MacBook-Pro:gitfoo ben$ g d
diff --git a/foo b/foo
index 257cc56..3bd1f0e 100644
--- a/foo
+++ b/foo
@@ -1 +1,2 @@
foo
+bar
Maurices-MacBook-Pro:gitfoo ben$ g c -am 'change 1'
[branch-1 6c27a3d] change 1
1 files changed, 1 insertions(+), 0 deletions(-)
Maurices-MacBook-Pro:gitfoo ben$ echo 'baz' >> foo
Maurices-MacBook-Pro:gitfoo ben$
Maurices-MacBook-Pro:gitfoo ben$ g d
diff --git a/foo b/foo
index 3bd1f0e..86e041d 100644
--- a/foo
+++ b/foo
@@ -1,2 +1,3 @@
foo
bar
+baz
Maurices-MacBook-Pro:gitfoo ben$ g c -am 'change 2'
[branch-1 37ef707] change 2
1 files changed, 1 insertions(+), 0 deletions(-)
Maurices-MacBook-Pro:gitfoo ben$
Maurices-MacBook-Pro:gitfoo ben$
Maurices-MacBook-Pro:gitfoo ben$ g d
Maurices-MacBook-Pro:gitfoo ben$ g l
commit 37ef70751f7394cb32135fdfb2ee3baf0fa8093e
Author: Ben Kempner <ben@verticalbrands.com>
Date: Wed May 30 15:00:22 2012 -0700
change 2
commit 6c27a3da9d242f46fe06f858d5a9cb616de6397d
Author: Ben Kempner <ben@verticalbrands.com>
Date: Wed May 30 15:00:10 2012 -0700
change 1
commit 858db259df9a40df840dfbd584e75b9a49936382
Author: Ben Kempner <ben@verticalbrands.com>
Date: Wed May 30 14:59:44 2012 -0700
initial commit
Maurices-MacBook-Pro:gitfoo ben$ g co master
Switched to branch 'master'
Maurices-MacBook-Pro:gitfoo ben$ g cherry-pick 37ef70751f7394cb32135fdfb2ee3baf0fa8093e
error: could not apply 37ef707... change 2
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit -c 37ef707'
Maurices-MacBook-Pro:gitfoo ben$ g d
diff --cc foo
index 257cc56,86e041d..0000000
--- a/foo
+++ b/foo
@@@ -1,1 -1,3 +1,6 @@@
foo
++<<<<<<< HEAD
++=======
+ bar
+ baz
++>>>>>>> 37ef707... change 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment