Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Committing partial Hunks in Git

Tags:

If I made two logical changes, which is continuous in code. Git shows it as one single hunk while adding interactively.

Is there a way to specifically add only few lines in a hunk, during add --patch?

like image 437
Sathish Manohar Avatar asked Mar 02 '11 09:03

Sathish Manohar


1 Answers

The git add --patch mode has option for splitting an individual hunk or editing an individual hunk.

git add --patch:

s - split the current hunk into smaller hunks e - manually edit the current hunk 

Wouldn't that solve your issue regarding your continuous set of lines?

After adding partials to commit, User should use ONLY git commit to commit, using git commit -a or using commit with all files flag ignores added partial and commits all staged files.

like image 133
VonC Avatar answered Sep 21 '22 17:09

VonC