[diff] colorMoved = mode
[color "diff"] new = bold green old = bold red newMoved = dim green oldMoved = dim red
BEFORE : this is a nice line of code 1 this is a nice line of code 2 this is a nice line of code 3 [master (root-commit) d25ae79] initial version 1 file changed, 3 insertions(+) create mode 100644 myFile AFTER : this is a GREAT line of code 1 this is a nice line of code 3 this is a nice line of code 2 git diff --color-moved=no : diff --git i/myFile w/myFile index 574049d..7d015c9 100644 --- i/myFile +++ w/myFile @@ -1,3 +1,3 @@ -this is a nice line of code 1 -this is a nice line of code 2 +this is a GREAT line of code 1 this is a nice line of code 3 +this is a nice line of code 2 git diff --color-moved=default : diff --git i/myFile w/myFile index 574049d..7d015c9 100644 --- i/myFile +++ w/myFile @@ -1,3 +1,3 @@ -this is a nice line of code 1 -this is a nice line of code 2 +this is a GREAT line of code 1 this is a nice line of code 3 +this is a nice line of code 2
git add --patch myFile, then for each hunk :
It is possible to do the opposite; i.e. interactively select hunks to unstage with git reset -p.
line 1
' >> "$myFile"; git add "$myFile"; git commit -m 'Initial version'
line 2\nline 3
" >> "$myFile"line 1 line 2 line 3
diff --git a/testFile b/testFile index 89b24ec..a92d664 100644 --- a/testFile +++ b/testFile @@ -1 +1,3 @@ line 1 +line 2 +line 3
And the question is : how may I stage line 2
split from line 3
so that I can make 2 separate commits ?
diff --git a/testFile b/testFile index 89b24ec..a92d664 100644 --- a/testFile +++ b/testFile @@ -1 +1,3 @@ line 1 +line 2 +line 3 Stage this hunk [y,n,q,a,d,/,e,?]?
# Manual hunk edit mode -- see bottom for a quick guide @@ -1 +1,3 @@ line 1 +line 2 #+line 3 # --- # To remove '-' lines, make them ' ' lines (context). # To remove '+' lines, delete them. # Lines starting with # will be removed. # # If the patch applies cleanly, the edited hunk will immediately be # marked for staging. If it does not apply cleanly, you will be given # an opportunity to edit again. If all lines of the hunk are removed, # then the edit is aborted and the hunk is left unchanged.
To not stage a ... line | Do : |
---|---|
+ |
|
- | change the leading - into a [SPACE] |
diff --git a/testFile b/testFile index 89b24ec..7bba8c8 100644 --- a/testFile +++ b/testFile @@ -1 +1,2 @@ line 1 +line 2
commit 7d7a786c1353b5433b7e39a6b50c7ac8d9b5159f Author: Thomas ANDERSON <thomas.anderson@metacortex.com> who made the commit Date: Fri Jul 18 09:35:36 2014 +0200 Fixed a glitch in the Matrix Signed-off-by: Smith <smith@thematrix> who applied the patch