Hard reset of a single file
To discard local changes and restore a specific file back to its last committed state without affecting the rest of your project, you can use either the modern command git restore filename.txt or the traditional command git checkout -- filename.txt, both of which safely reset only the targeted file while leaving all…
Answered Sep 23, 2026 · 878 Views Read answer →