How does the index/staging area let you build up a commit with only part of your changes, e.g. with git add -p?
Last updated
The index (staging area) sits between your files and the repo. Commits are built from the index, not directly from your working directory.
git add -pwalks through each change "hunk" so you can stage it (y), skip it (n), split it (s), or edit it (e).This keeps commits atomic (e.g. leaving debug lines unstaged), and
git diff --stagedconfirms what you selected.
- https://en.wpmm.jp/blog/git-staging-area-add-commit-explained/
- https://www.geeksforgeeks.org/git/staging-in-git/
- https://filip-prochazka.com/blog/git-commit-only-parts-of-a-file
- https://git-scm.com/book/en/v2/Git-Tools-Interactive-Staging
- https://git-scm.com/book/it/v2/Git-Tools-Interactive-Staging
- https://betterstack.com/community/questions/commit-only-part-of-file-in-git/
- https://www.atlassian.com/git/tutorials/saving-changes
- https://dev.to/theramoliya/git-interactive-add-for-precise-staging-33m1