If you have committed the wrong files to Git, what command can you use to undo this last commit?
- git reset --soft HEAD^
- git revert HEAD
- git reset --hard HEAD^
- git reset HEAD^
The correct option, git reset --hard HEAD^, is also used in this scenario to completely undo the last commit along with the changes. It discards the commit and resets the branch pointer. Other options are for different use cases: preserving changes, creating a new commit to undo changes, and unstaging changes.
Loading...
Related Quiz
-
The command git _______
is used to clone a remote repository to your local machine. - In Git, __________ can be used to verify the integrity and origin of commits.
- In a project with multiple contributors, two developers have made different changes to the same file. What Git feature will help resolve this when merging?
- In a Bitbucket repository, how can a team automate the process of sending notifications to a chat service after each commit?
- GitLab’s CI/CD pipelines can be configured through a file named _________.