Interview Prep/Git & GitHub/Commits, branches and tags

How do you commit only part of the changes in a file?

BeginnerConceptCommits, branches and tags
Answer

Use interactive patch staging. Git splits the diff into hunks and asks per hunk: y stage, n skip, s split, e edit manually.

git add -p path/to/file
git diff --staged
All Git & GitHub questions Roadmap: Git & GitHub

More on Commits, branches and tags