Git: committing only partial changes of a file
Posted on December 30th, 2010 in git | 1 Comment »
or better known as “staging patches”.
So you created some new functionality in a file but you have a lot of other code you’re not quite ready to commit yet. Answer: git add -p
. It will interactively go though modified sections of your file asking if you want to “stage this hunk”. Answer y for yes, n for no, q for stop, then commit as usual. You can even split hunks if you want to get more fine-grained.
For more details check out this page.
One Response
Thanks that worked for me. Any ideas how to undo this git add -p operation? For example, if said “yes” to one hunk and then I want to undo it?