File tree 2 files changed +32
-1
lines changed
2 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
10
10
11
11
For a steady stream of TILs, [ sign up for my newsletter] ( https://tinyletter.com/jbranchaud ) .
12
12
13
- _ 1019 TILs and counting..._
13
+ _ 1020 TILs and counting..._
14
14
15
15
---
16
16
@@ -279,6 +279,7 @@ _1019 TILs and counting..._
279
279
- [ Stashing Untracked Files] ( git/stashing-untracked-files.md )
280
280
- [ Switch To A Recent Branch With FZF] ( git/switch-to-a-recent-branch-with-fzf.md )
281
281
- [ 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 )
282
283
- [ Untrack A Directory Of Files Without Deleting] ( git/untrack-a-directory-of-files-without-deleting.md )
283
284
- [ Untrack A File Without Deleting It] ( git/untrack-a-file-without-deleting-it.md )
284
285
- [ Update The URL Of A Remote] ( git/update-the-url-of-a-remote.md )
Original file line number Diff line number Diff line change
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.
You can’t perform that action at this time.
0 commit comments