How to Stage Partial Changes Using Git’s add -p Command

Git developers often need to commit only parts of modified files. The add -p option lets users interactively choose hunks to stage. Running git add -p

Git developers often need to commit only parts of modified files. The add -p option lets users interactively choose hunks to stage. Running git add -p presents each change chunk and prompts for action. Users can type 'y' to stage, 'n' to skip, or 's' to split larger hunks. The command supports shortcuts like 'a' to stage all remaining hunks. It also allows editing a hunk before staging with the 'e' option. This workflow helps keep commits focused and easier to review. Applying add -p is useful for clean history and collaborative code reviews.