git reset --hard throws away your code. Use it carefully

calendar_today timer Reading time ~1 minute

This git command deletes your code. Most people misuse it.

git reset --hard throws away the changes in those commits, not just the commits. Only use it when you are sure. If you regret it, reflog can usually bring it back.

Soft or default reset keeps your changes in place, so reach for those first.

Want the full breakdown of soft, mixed, and hard reset? Watch the full video: Undo anything in Git

Follow for the safe way to undo anything in git!

animated jess' signature

Related Articles