Which statement correctly describes the difference between git reset and git revert?
Think about whether the command changes history or adds a new commit.
git reset moves the HEAD pointer and can change commit history, which can be dangerous if pushed. git revert safely undoes changes by adding a new commit, preserving history.
What is the output of running git revert HEAD in a repository?
git revert HEADConsider what git revert does to the commit history.
git revert HEAD creates a new commit that undoes the changes introduced by the last commit. It does not delete commits.
What happens to your working directory and commit history after running git reset --hard HEAD~2?
git reset --hard HEAD~2
Think about what --hard does to files and commits.
git reset --hard HEAD~2 moves HEAD back two commits and resets the working directory and staging area to match that commit, discarding all changes after it.
You accidentally committed some incorrect changes and pushed them to a shared remote repository. Which approach is safer to undo those changes without disrupting other collaborators?
Consider the impact on collaborators and history rewriting.
git revert safely undoes changes by adding a new commit, avoiding history rewrite that can confuse collaborators. git reset --hard with force push rewrites history and can cause problems.
After running git reset --mixed HEAD~1, you notice some files in your working directory have unexpected changes. Why does this happen?
Recall the difference between --soft, --mixed, and --hard options.
--mixed resets the staging area to the specified commit but does not change the working directory. So, file changes remain visible but unstaged.