Skip to content

Commit 5ab61e5

Browse files
committed
Add Interactively Unstage Changes as a git til
1 parent f1d3d1f commit 5ab61e5

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ _326 TILs and counting..._
8080
- [Grep Over Commit Messages](git/grep-over-commit-messages.md)
8181
- [Ignore Changes To A Tracked File](git/ignore-changes-to-a-tracked-file.md)
8282
- [Intent To Add](git/intent-to-add.md)
83+
- [Interactively Unstage Changes](git/interactively-unstage-changes.md)
8384
- [Last Commit A File Appeared In](git/last-commit-a-file-appeared-in.md)
8485
- [List Filenames Without The Diffs](git/list-filenames-without-the-diffs.md)
8586
- [List Most Git Commands](git/list-most-git-commands.md)
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Interactively Unstage Changes
2+
3+
I often use `git add --patch` to interactively stage changes for a commit.
4+
Git takes me through changes to tracked files piece by piece to check if I
5+
want to stage them. This same interactive _staging_ of files can be used in
6+
reverse when removing changes from the index. Just add the `--patch` flag.
7+
8+
You can use it for a single file
9+
10+
```bash
11+
$ git reset --patch README.md
12+
```
13+
14+
or you can let it operate on the entire repository
15+
16+
```bash
17+
$ git reset --patch
18+
```
19+
20+
This is useful when you've staged part of a file for a commit and then
21+
realize that some of those changes shouldn't be committed.

0 commit comments

Comments
 (0)