B.D
B.D

Reputation: 183

Git - Split current hunk into line so I can commit separately when use git add -p

I add two lines into my file

@@ -2,3 +2,5 @@ i am original.
 I am the second change.
 my 3rd line
 this is the 4th change
+I am 5th change
+I am 6 change

The 's' can not split it into line, any ideas? I know there is "manually edit hunk", but I don't think it can split the two lines.

Upvotes: 0

Views: 107

Answers (1)

Daniel H
Daniel H

Reputation: 7463

If you manually edit the hunk, you can get rid of the +I am 6 change line, and then commit. The I am 6 change line is still present in the original file (git add -p, even with editing hunks, does not touch the working tree), so you just add the file and commit again to get that change separately.

Upvotes: 2

Related Questions