0

I'm sure this is a duplicate, but whenever I google, I can't find an answer. Let's say I do a git status and 3 files are modified. It doesn't matter if they're staged, unstaged, or whatever. I want to reset one of those files back to their HEAD state, effectively doing a git reset --hard, but only for that one file. How do I do that? I'm looking for a universal command, not a "if it's staged, do x, if it's unstaged, do y." Does such a command exist?

Daniel Kaplan
  • 62,768
  • 50
  • 234
  • 356

1 Answers1

1

git checkout HEAD -- <file>

Anas Alkhatib
  • 1,110
  • 1
  • 9
  • 22