mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 07:08:01 +00:00
Add Interactively Unstage Changes as a git til
This commit is contained in:
@@ -80,6 +80,7 @@ _326 TILs and counting..._
|
|||||||
- [Grep Over Commit Messages](git/grep-over-commit-messages.md)
|
- [Grep Over Commit Messages](git/grep-over-commit-messages.md)
|
||||||
- [Ignore Changes To A Tracked File](git/ignore-changes-to-a-tracked-file.md)
|
- [Ignore Changes To A Tracked File](git/ignore-changes-to-a-tracked-file.md)
|
||||||
- [Intent To Add](git/intent-to-add.md)
|
- [Intent To Add](git/intent-to-add.md)
|
||||||
|
- [Interactively Unstage Changes](git/interactively-unstage-changes.md)
|
||||||
- [Last Commit A File Appeared In](git/last-commit-a-file-appeared-in.md)
|
- [Last Commit A File Appeared In](git/last-commit-a-file-appeared-in.md)
|
||||||
- [List Filenames Without The Diffs](git/list-filenames-without-the-diffs.md)
|
- [List Filenames Without The Diffs](git/list-filenames-without-the-diffs.md)
|
||||||
- [List Most Git Commands](git/list-most-git-commands.md)
|
- [List Most Git Commands](git/list-most-git-commands.md)
|
||||||
|
|||||||
21
git/interactively-unstage-changes.md
Normal file
21
git/interactively-unstage-changes.md
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Interactively Unstage Changes
|
||||||
|
|
||||||
|
I often use `git add --patch` to interactively stage changes for a commit.
|
||||||
|
Git takes me through changes to tracked files piece by piece to check if I
|
||||||
|
want to stage them. This same interactive _staging_ of files can be used in
|
||||||
|
reverse when removing changes from the index. Just add the `--patch` flag.
|
||||||
|
|
||||||
|
You can use it for a single file
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ git reset --patch README.md
|
||||||
|
```
|
||||||
|
|
||||||
|
or you can let it operate on the entire repository
|
||||||
|
|
||||||
|
```bash
|
||||||
|
$ git reset --patch
|
||||||
|
```
|
||||||
|
|
||||||
|
This is useful when you've staged part of a file for a commit and then
|
||||||
|
realize that some of those changes shouldn't be committed.
|
||||||
Reference in New Issue
Block a user