Created
January 23, 2012 19:25
-
-
Save ahamid/1665057 to your computer and use it in GitHub Desktop.
selectively adding hunk
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[aaron@msi-cr620 workspace]$ cd hunk-test/ | |
[aaron@msi-cr620 hunk-test]$ git init . | |
Initialized empty Git repository in /home/aaron/workspace/hunk-test/.git/ | |
[aaron@msi-cr620 hunk-test]$ git branch | |
[aaron@msi-cr620 hunk-test]$ git branch -v | |
[aaron@msi-cr620 hunk-test]$ git status | |
# On branch master | |
# | |
# Initial commit | |
# | |
nothing to commit (create/copy files and use "git add" to track) | |
[aaron@msi-cr620 hunk-test]$ echo -e "my favorite\nice cream\nis chocolate" > test.txt | |
[aaron@msi-cr620 hunk-test]$ git add test.txt | |
[aaron@msi-cr620 hunk-test]$ git commit -m 'initial commit' | |
[master (root-commit) bc6a6d8] initial commit | |
1 files changed, 3 insertions(+), 0 deletions(-) | |
create mode 100644 test.txt | |
[aaron@msi-cr620 hunk-test]$ git checkout -b speculative_work | |
Switched to a new branch 'speculative_work' | |
[aaron@msi-cr620 hunk-test]$ echo -e "my favorite\ncolor\nand berry\nis blue" > test.txt | |
[aaron@msi-cr620 hunk-test]$ git diff test.txt | |
diff --git a/test.txt b/test.txt | |
index 1f35f19..9fbffde 100644 | |
--- a/test.txt | |
+++ b/test.txt | |
@@ -1,3 +1,4 @@ | |
my favorite | |
-ice cream | |
-is chocolate | |
+color | |
+and berry | |
+is blue | |
[aaron@msi-cr620 hunk-test]$ git add test.txt; git commit -m 'unstable work' | |
[speculative_work 1f946b2] unstable work | |
1 files changed, 3 insertions(+), 2 deletions(-) | |
[aaron@msi-cr620 hunk-test]$ git checkout master | |
Switched to branch 'master' | |
[aaron@msi-cr620 hunk-test]$ git checkout -b dev | |
Switched to a new branch 'dev' | |
[aaron@msi-cr620 hunk-test]$ git log --help | |
[aaron@msi-cr620 hunk-test]$ git log speculative_work | |
commit 1f946b2a8e91c9e85707628d6d00cf7e2395776d | |
Author: Aaron Hamid <[email protected]> | |
Date: Mon Jan 23 14:18:32 2012 -0500 | |
unstable work | |
commit bc6a6d8d0402177096c64b50ace9b748ec9877f4 | |
Author: Aaron Hamid <[email protected]> | |
Date: Mon Jan 23 14:16:55 2012 -0500 | |
initial commit | |
[aaron@msi-cr620 hunk-test]$ git checkout -p 1f946b2a8e91c9e85707628d6d00cf7e2395776d test.txt | |
diff --git b/test.txt a/test.txt | |
index 1f35f19..9fbffde 100644 | |
--- b/test.txt | |
+++ a/test.txt | |
@@ -1,3 +1,4 @@ | |
my favorite | |
-ice cream | |
-is chocolate | |
+color | |
+and berry | |
+is blue | |
Apply this hunk to index and worktree [y,n,q,a,d,/,e,?]? e | |
[aaron@msi-cr620 hunk-test]$ git status | |
# On branch dev | |
# Changes to be committed: | |
# (use "git reset HEAD <file>..." to unstage) | |
# | |
# modified: test.txt | |
# | |
[aaron@msi-cr620 hunk-test]$ git diff test.txt | |
[aaron@msi-cr620 hunk-test]$ git commit -m 'selectively added hunk' | |
[dev 3eae06f] selectively added hunk | |
1 files changed, 2 insertions(+), 1 deletions(-) | |
[aaron@msi-cr620 hunk-test]$ git checkout master | |
Switched to branch 'master' | |
[aaron@msi-cr620 hunk-test]$ git merge --no-ff dev | |
Merge made by the 'recursive' strategy. | |
test.txt | 3 ++- | |
1 files changed, 2 insertions(+), 1 deletions(-) | |
[aaron@msi-cr620 hunk-test]$ git checkout speculative_work | |
Switched to branch 'speculative_work' | |
[aaron@msi-cr620 hunk-test]$ git rebase master | |
First, rewinding head to replay your work on top of it... | |
Applying: unstable work | |
Using index info to reconstruct a base tree... | |
Falling back to patching base and 3-way merge... | |
Auto-merging test.txt | |
CONFLICT (content): Merge conflict in test.txt | |
Failed to merge in the changes. | |
Patch failed at 0001 unstable work | |
When you have resolved this problem run "git rebase --continue". | |
If you would prefer to skip this patch, instead run "git rebase --skip". | |
To check out the original branch and stop rebasing run "git rebase --abort". | |
[aaron@msi-cr620 hunk-test]$ git status | |
# Not currently on any branch. | |
# Unmerged paths: | |
# (use "git reset HEAD <file>..." to unstage) | |
# (use "git add/rm <file>..." as appropriate to mark resolution) | |
# | |
# both modified: test.txt | |
# | |
no changes added to commit (use "git add" and/or "git commit -a") | |
[aaron@msi-cr620 hunk-test]$ git diff test.txt | |
diff --cc test.txt | |
index 56c2a8f,9fbffde..0000000 | |
--- a/test.txt | |
+++ b/test.txt | |
@@@ -1,4 -1,4 +1,8 @@@ | |
my favorite | |
++<<<<<<< HEAD | |
+ice cream | |
++======= | |
+ color | |
++>>>>>>> unstable work | |
and berry | |
is blue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment