Last Updated: February 25, 2016
· annacoder

Patch committing in git

When you use git add <filename>, git stages all the local diffs in that file for committing but if you give the -p option (as in git add -p <filename>) git will interactively let you select only some of the diffs in <filename>.

This is useful when you have multiple changes in a file but you need to split up the changes across different commits or if you want to suppress some of the changes from being committed.

This works for any pathspec (example, glob of files).