← Useful Tips
GitGit

git add -p: Stage only selected hunks from a changed file

Use git add -p to stage only selected hunks from a changed file. It makes version-control work faster and reduces avoidable mistakes.

git add -p

Why it helps

Use git add -p to stage only selected hunks from a changed file. It makes version-control work faster and reduces avoidable mistakes.

How to use it

  1. Open the relevant app or terminal.
  2. Use the shortcut or command above in the relevant context.
  3. Check the result; for commands that change data, test on a small example first.
People also search for
git add -p: Stage only selected hunks from a changed filegit add -pstage only selected hunks from a changed filehow to stage only selected hunks from a changed fileGit stage only selected hunks from a changed file

Related tips