mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 15:18:01 +00:00
Add Unstage Changes With Git Restore as a git til
This commit is contained in:
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
|
|||||||
|
|
||||||
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
|
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
|
||||||
|
|
||||||
_1019 TILs and counting..._
|
_1020 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -279,6 +279,7 @@ _1019 TILs and counting..._
|
|||||||
- [Stashing Untracked Files](git/stashing-untracked-files.md)
|
- [Stashing Untracked Files](git/stashing-untracked-files.md)
|
||||||
- [Switch To A Recent Branch With FZF](git/switch-to-a-recent-branch-with-fzf.md)
|
- [Switch To A Recent Branch With FZF](git/switch-to-a-recent-branch-with-fzf.md)
|
||||||
- [Two Kinds Of Dotted Range Notation](git/two-kinds-of-dotted-range-notation.md)
|
- [Two Kinds Of Dotted Range Notation](git/two-kinds-of-dotted-range-notation.md)
|
||||||
|
- [Unstage Changes Wih Git Restore](git/unstage-changes-with-git-restore.md)
|
||||||
- [Untrack A Directory Of Files Without Deleting](git/untrack-a-directory-of-files-without-deleting.md)
|
- [Untrack A Directory Of Files Without Deleting](git/untrack-a-directory-of-files-without-deleting.md)
|
||||||
- [Untrack A File Without Deleting It](git/untrack-a-file-without-deleting-it.md)
|
- [Untrack A File Without Deleting It](git/untrack-a-file-without-deleting-it.md)
|
||||||
- [Update The URL Of A Remote](git/update-the-url-of-a-remote.md)
|
- [Update The URL Of A Remote](git/update-the-url-of-a-remote.md)
|
||||||
|
|||||||
30
git/unstage-changes-with-git-restore.md
Normal file
30
git/unstage-changes-with-git-restore.md
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# Unstage Changes With Git Restore
|
||||||
|
|
||||||
|
Git 2.23 introduced the `restore` command which is a more direct alternative to
|
||||||
|
`checkout` and `reset` for restoring the state of the working tree and the
|
||||||
|
index (staging area).
|
||||||
|
|
||||||
|
With the `--staged` flag, we can unstage changes, moving them from the index to
|
||||||
|
the working tree.
|
||||||
|
|
||||||
|
> To restore a file in the index to match the version in HEAD (this is the same
|
||||||
|
> as using git-reset(1))
|
||||||
|
|
||||||
|
```
|
||||||
|
$ git restore --staged README.md
|
||||||
|
```
|
||||||
|
|
||||||
|
Staged changes to `README.md` will be removed from the index and put on the
|
||||||
|
working tree.
|
||||||
|
|
||||||
|
```
|
||||||
|
$ git restore --staged .
|
||||||
|
```
|
||||||
|
|
||||||
|
That will unstage all changes on the index.
|
||||||
|
|
||||||
|
This is now recommended by Git when you run `git status`:
|
||||||
|
|
||||||
|
> (use "git restore --staged <file>..." to unstage)
|
||||||
|
|
||||||
|
See `man git-restore` for more details.
|
||||||
Reference in New Issue
Block a user