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

Let's say you were working on an update but needed to push some partial code. To do it, you can quickly call the interactive add feature of git and select the portion of code you want.

Let's say you were working on an update but needed to push some partial code in a fix or another 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 the following:

git add -p

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

Originally Posted On: Github (k88hudson)

Subscribe to GIT.WTF!?!

Don’t miss out on the latest issues. Sign up now to get access to the library of members-only issues.
[email protected]
Subscribe