correct add -e

This commit is contained in:
2026-05-14 20:02:01 +03:00
parent 862b8b2fb0
commit 0380bb18bb

View File

@@ -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: additions in the working tree (will be staged if kept).
- `-` lines: deletions 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. - Context lines (no prefix): unchanged lines needed for patch context.
- To stage a change: keep the `+` or `-` line in the patch. - To stage an addition: keep the `+` line in the patch.
- To NOT stage a change: **delete** the `+` or `-` line from 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. - 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. - If you want to decline the operation entirely, delete all lines of the patch.
- **To remove an added line (`+`) from being staged, delete the entire line.** - If you break the patch, run `git checkout -- <file>` to undo, then run `git add -e` again.
- If you break the patch, run `git checkout -- <file>` to undo, then run `git add -e` again.
## Git Add Hunks ## Git Add Hunks
### `git add -p` ### `git add -p`
Select hunks of changes interactively. This allows you to stage only parts of the changes in a file.\ Select hunks of changes interactively. This allows you to stage only parts of the changes in a file.\