Search code examples
gitvisual-studiogit-for-windowsgit-stage

Undo GIT Stage and get local changes back


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.


Solution

  • 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).