It’s often handy to add changes you’ve made to your local branch in git in a more interactive fashion. Sometimes the changes you have make more sense in multiple commits than one catch all commit.
It’s quite easy to do this in git and here’s how:
git add -p
-p flag say to add changes interactively, breaking cohesive changes up into chunks. Here’s roughly what it will look like:
Now that you see your changes, you have a few options:
y– Add the given chunk.
n– Skip the given chunk (eg “next”).
s– Split the given chunk up into smaller chunks.
q– Stop adding chunks and exit out of
?– See all the other available sub commands.
Hope that’s helpful.