When would you use git checkout instead of git reset to undo changes?

  • git checkout is used for switching branches
  • git checkout discards changes in the working directory
  • git reset is used for switching branches
  • git reset discards changes in the working directory
The correct option is git checkout. It is used to discard changes in the working directory by replacing them with the last committed version. On the other hand, git reset is more commonly used for moving the branch pointer and can be more powerful, potentially discarding commits. git checkout is a safer option for simply undoing changes in the working directory.
Add your answer
Loading...

Leave a comment

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