I have done a GIT Stage from Visual Studio accidentally. There are some files which I don't want to commit. Therefore I want to undo my Stage action and get my local changes back.
Asked
Active
Viewed 200 times
1 Answers
3
The reverse action is
git reset -- path/to/file
It'll unstage this file but actual changes in the file are kept, they now appear as "unstaged changes".
You can also add multiple paths separated by spaces
git reset -- path/to/file some/other/path/*
The nuclear option (unstage everything) being the very concise :
git reset
Some examples from the doc :
To reset a single file, here.
To reset multiple files, there (although for this one you don't need their step (4) which is very specific to the context).

Romain Valeri
- 19,645
- 3
- 36
- 61
-
What if I want to unstage all the files in the solution? there are about 100 files which got staged and I don't even remember some paths. – Kasun Oct 26 '20 at 13:48
-
@KasunG Good question, I should have mentioned it, you're right. Edited. – Romain Valeri Oct 26 '20 at 13:50
-
1@KasunG As a sidenote, if you ever need to have the list of everything that's already staged, use `git diff --staged --name-only`. If we didn't have the nuclear option above, we could as well do the same like this `git reset -- $(git diff --staged --name-only)` – Romain Valeri Oct 26 '20 at 14:10