How to discard local commits in Git?


I'd been working on something, and decided it was completely screwed...after having committed some of it. So I tried the following sequence:

git reset --hard
git rebase origin
git fetch
git pull
git checkout

At which point I got the message

Your branch is ahead of 'origin/master' by 2 commits.

I want to discard my local commits, without having to wipe out my local directory and redownload everything. How can I accomplish that?


git reset --hard origin/master

will remove all commits not in origin/master where origin is the repo name and master is the name of the branch.

Git: Create a branch from unstaged/uncommitted changes on master

Show which git tag you are on?