From 5933dca536f41aa6a772745cb2931b117fdd11fb Mon Sep 17 00:00:00 2001 From: Jonathan Agmon Date: Fri, 17 Apr 2026 23:06:49 +0300 Subject: [PATCH] correct adding flow usage --- git/add.md | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/git/add.md b/git/add.md index 37c7976..237d527 100644 --- a/git/add.md +++ b/git/add.md @@ -5,12 +5,16 @@ Select lines of changes interactively. This allows you to stage only specific li Pros: More control over what gets staged. Cons: More manual work, you have to edit the patch file yourself, which can be error-prone and time-consuming. #### Guidelines: -- staged changes are marked with a "+" at the beginning of the line. -- unstaged changes are marked with a "-" at the beginning of the line. -- unchanged lines are not marked. -- To stage a change, add a "+" at the beginning of the line. -- To unstage a change, add a "-" at the beginning of the line. -- To keep a line unchanged, leave it as is. +- The editor shows a unified diff patch of working tree changes. +- `+` 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 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. ## Git Add Hunks ### `git add -p` Select hunks of changes interactively. This allows you to stage only parts of the changes in a file.\ @@ -27,5 +31,5 @@ Cons: Sometimes split won't work, which will force you to use the -e method. - `a` to stage this hunk and all remaining hunks - `d` to leave this hunk and all remaining hunks unstaged - If you choose `s`, Git will attempt to split the hunk into smaller hunks so you can stage a smaller section. -- If you choose `e`, Git opens the patch in a temporary editor; add `+` to lines to stage, `-` to lines to keep unstaged, then save and close. +- If you choose `e`, Git opens the patch in a temporary editor; delete `+` or `-` lines you do NOT want staged, then save and close. - When finished, run `git status` to verify which hunks were staged. \ No newline at end of file