Which Git command is used to undo the last commit while keeping the changes in the working directory?
- git reset HEAD~1
- git revert HEAD
- git commit --amend
- git checkout -- .
The correct option is git reset HEAD~1. This command resets the last commit while keeping the changes in the working directory. The HEAD~1 refers to the commit before the last one.
Loading...
Related Quiz
- How does the git reflog command assist in recovering lost commits?
- A development team is experiencing slow performance when working with a Git repository containing large binary files. What Git feature should they consider implementing?
- What is the primary purpose of the .gitignore file in a Git repository?
- Describe the role of 'feature branches' in Git's branching model.
- The git ________ command provides a byte-wise comparison between two branches to diagnose corruption or discrepancies.