Unstaging files
Unstage one file
git reset HEAD -- file.txt
Clears one index entry. The edit stays in the working tree and shows up as unstaged. See git-reset.
Unstage every file
git reset
Unstages everything. With no arguments, reset matches the index to HEAD from any directory; file contents stay unchanged. See git-reset.
Unstage selected hunks
git reset -p -- file.txt
Unstages interactively. Answer the prompts to unstage only part of a file. See git-reset.
Use git restore
git restore --staged file.txt
Unstages the path. restore --staged is the focused form of a path-limited reset. See git-restore.
Related links
- git-reset manual (git-scm.com)
- Git cheatsheet (devhints.io)
0 Comments for this cheatsheet. Write yours!