A developer accidentally committed a file that should not be tracked by Git. What command should they use to rectify this before pushing?
- git reset HEAD
- git rm --cached
- git checkout -- filename
- git revert
The correct option is c. git checkout -- filename. This command discards changes in the working directory and unstages the file, effectively "uncommitting" it. git reset HEAD and git rm --cached are used for different purposes. git reset HEAD unstages changes, and git rm --cached unstages the file but also stages the removal. git revert is used to create a new commit that undoes a previous commit.
Loading...
Related Quiz
- In complex projects, integrating Git with IDEs enables _________ tracking for each branch.
- Cloud platforms like GitHub provide _________ to facilitate tracking issues and tasks related to the codebase.
- When you want to combine histories of multiple repositories, a git __________ can be a suitable approach.
- A tag in Git is like a bookmark to a specific ________ in the repository's history.
- Which Git hook would you use to run scripts before a commit is finalized?