What Git command would you use to discard changes in a specific file before it has been staged?

  • git checkout -- filename
  • git reset HEAD filename
  • git restore filename
  • git revert filename
The correct option, git checkout -- filename, discards changes in a specific file before staging. It reverts the file to the last committed state. git reset HEAD filename unstages changes, git restore filename is used after staging, and git revert filename is for creating a new commit to undo changes.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *