How to add changes in one file to two different commits in git?

Written on by Sahil Bhatacharya in Solving Mistories

Let's say you were working on an update but need to push some partial code in a fix or some other update. To do it, you can quickly call the interactive add feature of git to select the portions of code you want to add using:

git add -p

This is also helpful if you want to be sure what you are adding.

Sign up below to receive updates, tips and more handy tutorials. It’s good stuff & I don’t spam.