Unstage a file (undo git add)
Safe: nothing is lost
Short answer
Run git restore --staged <file>. The file leaves the staging area, and your edits stay in the file.
The commands, one by one
- 1
git restore --staged notes.txtTakes
notes.txtout of the next commit. Its content on disk doesn't change. - 2
git status -sThe file now shows
Min the second column: changed, not staged.
For your own repository: Use your own file name. git restore --staged . unstages everything.