Unstage a File
Restore with --staged moves changes off the staging list. The changes stay in the file.
Stage the change
The coffee line waits on the staging list.
$ git add notes.txt
$ git statusMove it off the list
The change leaves the list but stays in the file.
$ git restore --staged notes.txt
$ git statusExample
$ git restore --staged notes.txt
$ git statusKey points
- Add stages a change. Restore with --staged unstages it.
- The file keeps the change. Only the staging list changes.
- Status shows the file as changed but not staged.
- Use it when you staged a file too early.
- The change is still there to stage again later.
Here, the file leaves the staging list. The change stays in the file, ready to stage again.
Note
--staged touches the list, not the file. The plain form touches the file.
Try it Yourself
Edit the code, then press Run.
Running is simulated
Exercise
What stays after git restore --staged?