It’s always fun when you find something entirely new, especially when it’s a quirk/feature on a tool that you use daily. This time around, I’ll be writing about git, in particular an option that you can use when stagging content for your next commit.

Most of the times, I either use git add <file> or if I’m sure that every unstaged change should be stagged, git add . will do the job. Today I found out the patch option: git add --patch or git add -p for short.

The patch option allows to interactively review every file that was changed. Instead of having to use diff to check what changed and add on the changes that you want to add, by using the patch option you can go through the changes and decide whether it makes sense to add it to the index or not.

Git add patch example

Feel free to check all the options that are available when using interactive stagging.