What does git reset --hard HEAD^ do?
a) Resets the current branch to the previous commit and deletes all uncommitted changes
b) Deletes the last commit but keeps the changes in the working directory
c) Reverts the last commit and stages the changes
d) Moves the
HEAD pointer to the first commitAnswer:
a) Resets the current branch to the previous commit and deletes all uncommitted changes
Explanation:
The git reset --hard HEAD^ command resets the current branch to the previous commit and deletes all uncommitted changes in both the working directory and staging area. It’s a forceful reset that discards all local changes.
This is useful when you want to completely undo the last commit and any modifications in the working directory, returning to a clean state.
Be careful when using this command, as it permanently deletes changes that aren’t committed.