Git is pretty good at branching and keeping everything neat and tidy. However, occasionally our branches get really messed up, and I have to clean things up. Here are a couple commands that I’ve found useful for this task.
Deleting Untracked Files
git clean -f -d
Abort a merge
git reset --merge
git reset --hard <COMMIT>
Note that you can always use the commit hash, but if you want to go back “N” commits, you can use the commit ID of “HEAD~N”. Notice this is a tidle, not a dash.
Throw away all local changes
git reset --hard origin/<BRANCH>