- If you have made multiple changes to a file but only want to stage/commit part of that file to git, you can use git's interactive staging tool.
git add -i
- Select
5
orp
for patch - Select the file(s) with the changes you want to interactively stage.
- Git will walk you through different chunks of code in the files you have selected, and you can pick if you want to stage that chunk of code.
- Once done, commit your code as normal.