What is the effect of git reset --hard HEAD^?

  • Moves HEAD to the previous commit
  • Discards changes in the working directory
  • Unstages changes from the index
  • Creates a new branch
The command git reset --hard HEAD^ resets the current branch to the previous commit, discarding all changes in the working directory and staging area. It's a forceful reset, so use it with caution as it cannot be undone.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *