↩️ UndoingCommonly used
How to unstage a file in Git
Remove a file from the staging area without losing changes.
Unstage a specific file
git restore --staged filename.txtRemoves the file from the staging area. Changes are kept in the working directory.
When to use: Modern Git (2.23+). Recommended.
Unstage a file (older syntax)
git reset HEAD filename.txtClassic way to unstage a file. Works in all Git versions.
Unstage all files
git restore --staged .Removes all files from the staging area. Changes are kept.
When to use: When you staged everything and want to start over.