Skip to content

Commit 9a9a68e

Browse files
committed
Add Unstage Changes With Git Restore as a git til
1 parent fe8a512 commit 9a9a68e

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
1010

1111
For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud).
1212

13-
_1019 TILs and counting..._
13+
_1020 TILs and counting..._
1414

1515
---
1616

@@ -279,6 +279,7 @@ _1019 TILs and counting..._
279279
- [Stashing Untracked Files](git/stashing-untracked-files.md)
280280
- [Switch To A Recent Branch With FZF](git/switch-to-a-recent-branch-with-fzf.md)
281281
- [Two Kinds Of Dotted Range Notation](git/two-kinds-of-dotted-range-notation.md)
282+
- [Unstage Changes Wih Git Restore](git/unstage-changes-with-git-restore.md)
282283
- [Untrack A Directory Of Files Without Deleting](git/untrack-a-directory-of-files-without-deleting.md)
283284
- [Untrack A File Without Deleting It](git/untrack-a-file-without-deleting-it.md)
284285
- [Update The URL Of A Remote](git/update-the-url-of-a-remote.md)
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Unstage Changes With Git Restore
2+
3+
Git 2.23 introduced the `restore` command which is a more direct alternative to
4+
`checkout` and `reset` for restoring the state of the working tree and the
5+
index (staging area).
6+
7+
With the `--staged` flag, we can unstage changes, moving them from the index to
8+
the working tree.
9+
10+
> To restore a file in the index to match the version in HEAD (this is the same
11+
> as using git-reset(1))
12+
13+
```
14+
$ git restore --staged README.md
15+
```
16+
17+
Staged changes to `README.md` will be removed from the index and put on the
18+
working tree.
19+
20+
```
21+
$ git restore --staged .
22+
```
23+
24+
That will unstage all changes on the index.
25+
26+
This is now recommended by Git when you run `git status`:
27+
28+
> (use "git restore --staged <file>..." to unstage)
29+
30+
See `man git-restore` for more details.

0 commit comments

Comments
 (0)