diff --git a/git/add.md b/git/add.md index 237d527..050b7c4 100644 --- a/git/add.md +++ b/git/add.md @@ -9,12 +9,16 @@ Cons: More manual work, you have to edit the patch file yourself, which can be e - `+` lines: additions in the working tree (will be staged if kept). - `-` lines: deletions in the working tree (will be staged if kept). - Context lines (no prefix): unchanged lines needed for patch context. -- To stage a change: keep the `+` or `-` line in the patch. -- To NOT stage a change: **delete** the `+` or `-` line from the patch. +- To stage an addition: keep the `+` line in the patch. +- To NOT stage an addition: **delete** the `+` line from the patch. +- To stage a deletion: keep the `-` line in the patch. +- To NOT stage a deletion: **convert the `-` to a space**. +- For modified content (shown with `-` lines followed by `+` lines): + - To NOT stage the modification: convert the `-` lines to spaces and remove the `+` lines. + - Note: modifying only half of the pair may cause confusing changes to the index. - To keep a line unchanged: leave context lines as-is. -- **Never change `+` or `-` to spaces or vice versa** — this breaks the patch format and causes "patch does not apply" errors. -- **To remove an added line (`+`) from being staged, delete the entire line.** - - If you break the patch, run `git checkout -- ` to undo, then run `git add -e` again. +- If you want to decline the operation entirely, delete all lines of the patch. +- If you break the patch, run `git checkout -- ` to undo, then run `git add -e` again. ## Git Add Hunks ### `git add -p` Select hunks of changes interactively. This allows you to stage only parts of the changes in a file.\