Skip to content

Commit 2946b8a

Browse files
committed
Add warning about git restore --staged -- <file>
Warn readers not to throw away their local work without meaning to. This is basically a copy/paste and adaptation of the warning we give about `git checkout -- <file>`.
1 parent 75a2a5a commit 2946b8a

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

book/02-git-basics/sections/undoing.asc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,4 +225,11 @@ Changes to be committed:
225225
(use "git restore --staged <file>..." to unstage)
226226
renamed: README.md -> README
227227
228-
----
228+
----
229+
230+
[IMPORTANT]
231+
=====
232+
It's important to understand that `git restore --staged <file>` is a dangerous command.
233+
Any local changes you made to that file are gone -- Git just replaced that file with the most recently-committed version.
234+
Don't ever use this command unless you absolutely know that you don't want those unsaved local changes.
235+
=====

0 commit comments

Comments
 (0)