Q:

Git: Complete sync (not merge) with remote repo

I don't want to just fetch changes from the remote repo and merge them into my local copy. I want to make my local copy identical to the remote repo. How can I do this?
I've messed up my repo somehow, but I know the remote repo is in solid shape. I have no work completed since my last push, so I don't care if I lose anything.

A:

1st: fetch the remote changes:
git fetch origin # or whatever your remote is called

2nd: Reset your branches to the state the remote is at:
git reset --hard origin/master # or whatever the branch and remote is called

This will set the pointer to the head commit of the remote branch and throw away all your changes. Repeat the second step for every branch you want to reset.

In case you created some files that you never commited:
git clean -ndx # check which files will be removed
git clean -fdx # actually remove them

