How can I unstage a file without discarding its edits?
Quick answer
To unstage a file without discarding its edits, remove it from the staging area—not from your working copy. In Visual Studio’s Git Changes view, click the minus button beside the staged file, or run git reset <file_path> for one file. Then check that it is no longer staged and appears among the unstaged changes. Avoid discard or revert actions when you want to preserve edits. [S1]
The question, the details, the next step.
A practical checklist
A few more useful answers
Does `git reset <file_path>` discard the file’s edits?
In the documented Visual Studio workflow, this command is the equivalent of unstaging a single file; it removes the staging selection rather than instructing you to discard the working copy. [S1]
Can I unstage a directory instead of one file?
The cited Visual Studio guidance says a directory path can be used to unstage a directory. Check the resulting Git Changes view afterward to confirm the status. [S1]
What should I see after unstaging in Visual Studio?
The file should leave Staged Changes and appear among modified, unstaged Changes if its working-copy edits remain. [S1]
Sources
References used for this guide.
- [S1] Make a Git commit in Visual Studio learn.microsoft.com · Checked
