Adding partial changes with Git

If you made several changes in a file, but only want to commit a portion of it, you can add the --patch option to the git add command.

git add file --patch

This will interactively walk you through the changes you made and let you specify what to include and what to leave out.

If git presents you with a chunk larger than what you would like to add, you can use the "e" interactive command to specify the exact lines that you want added or removed.