Clear all local changes

Published: September 20, 2019

Today I re-learned how to remove all changes done in your local repository

Restore modified or deleted paths to their original contents:

bash
git checkout .
git clean -fd

checkout . restores all tracked files, while clean remove untracked files where f is for files and d for directories.

If you have added files you can reset them to unstaged with:

bash
git reset

Undo all commits with:

bash
git reset --hard origin/master

This was mostly to have a recipe I can go back to later.