log / add change interactively in git

Overview

git add -p, -p or --patch - Interactively choose hunks of patch between the index and the work tree and add them to the index. This gives the user a chance to review the difference before adding modified contents to the index. (explanation from man page)

diff --git a/file.txt b/file.txt 
index 83db48f..f735ef1 100644
--- a/file.txt
+++ b/file.txt
@@ -1,4 +1,4 @@ 
-Old line 
+New line

Stage this hunk [y,n,q,a,d,s,e,?]?

Detailed Options

  • y (yes): Accepts the current hunk and stages it.
  • n (no): Skips the current hunk and does not stage it.
  • q (quit): Stops the interactive staging process.
  • a (all): Stages the current hunk and all subsequent hunks.
  • d (discard): Skips the current hunk and all subsequent hunks.
  • s (split): Breaks the current hunk into smaller parts to give more granular control.
  • e (edit): Opens an editor to manually modify which parts of the hunk to stage.
  • ? (help): Displays help text explaining all these options.
Written on 2024-06-25 15:13:00 +0700 Edited on 2024-06-25 15:18:00 +0700