File tree Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Expand file tree Collapse file tree 2 files changed +22
-0
lines changed Original file line number Diff line number Diff 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 )
Original file line number Diff line number Diff line change 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.
You can’t perform that action at this time.
0 commit comments