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.
Loading...
Related Quiz
- In Git, _______ can be used to temporarily switch to another branch without committing the current work.
- What is the purpose of a .gitignore file in a Git repository?
- A team working on a project hosted on GitHub wants to ensure code style consistency. Which feature should they implement?
- How does a lightweight tag in Git differ from an annotated tag?
- A development team is working on a feature that will take several weeks to complete. Which Git workflow model would best support their needs for isolation and regular integration?