Stage only part of a file in git

less than 1 minute read

In order to add only some lines of a file for committing, use git add -p <filename>. If the file is new, use git add -N <filename>. Look up this SO link for more.