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.
Loading...
Related Quiz
- A team wants to automatically test and deploy features as soon as they are pushed to a specific Git branch. Which CI/CD practice aligns with this?
- For an open source project on GitHub, what is the standard method for contributing changes?
- GitLab’s CI/CD pipelines can be configured through a file named _________.
- Discuss the advantages of integrating Git with cloud-based IDEs in a CI/CD pipeline.
- The git _______ command can be used to temporarily store uncommitted changes and clear the working directory.