How do you discard all changes from your local Git workspace?

Experience Level: Junior
Tags: Git Source control

Answer

To discard all changes from your local Git workspace, you can use the following commands:

  • git reset --hard - this will discard all changes permanently, discarded changes won't be preserved in any way
  • git stash - this will discard all changes, but will stash them away and you can restore them later using git stash pop command
Related Git job interview questions
Git for beginners
Git for beginners

Are you learning Git? Try our test we designed to help you progress faster.

Test yourself