won't-be-committed.gitignore :
cutside (source)
pasteside (destination)
This line has —not changed— since the previous commit. This line was —added— since the previous commit. This line was —removed— since the previous commit. This line was —cut— since the previous commit. This line was —pasted— since the previous commit.But these can be edited as you like (read below).
[diff] colorMoved = mode
[color "diff"] new = bold green old = bold red newMoved = dim green oldMoved = dim red
BEFORE : Let's go buy some apples. I want some. Banana is my favorite fruit. Who wants some coconut ? AFTER : Let's go buy some apples. I'll buy 4. Who wants some coconut ? Yes, please. Banana is my favorite fruit. git diff --color-moved=no : diff --git i/myFile w/myFile index ff718be..a8bb615 100644 --- i/myFile +++ w/myFile @@ -1,5 +1,6 @@ Let's go buy some apples. - I want some. -Banana is my favorite fruit. + I'll buy 4. Who wants some coconut ? + Yes, please. +Banana is my favorite fruit. git diff --color-moved=blocks : diff --git i/myFile w/myFile index ff718be..a8bb615 100644 --- i/myFile +++ w/myFile @@ -1,5 +1,6 @@ Let's go buy some apples. - I want some. -Banana is my favorite fruit. + I'll buy 4. Who wants some coconut ? + Yes, please. +Banana is my favorite fruit.
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
TO be proof-check / experienced / confirmed : applying the patch : - "git am ..." : the example below looks weird. To be checked again - "git apply <patch>" : tested and OK with a patch created with "git diff" :-)
commit 7d7a786c1353b5433b7e39a6b50c7ac8d9b5159f Author: Thomas ANDERSON <thomas.anderson@metacortex.com> who made the commit Date: Fri Jul 18 09:35:36 2014 +0200 FIX a glitch in the Matrix Signed-off-by: Smith <smith@thematrix> who applied the patch