Switching a branch after aborting current changes in git

Solution 1:

Option 1

git checkout -f gh-pages

Option 2

git reset --hard     # beware: don't make that a habit
git checkout gh-pages

Solution 2:

Just for the sake of completeness, and for those who landed here by searching: Although the OP asks specifically for a solution without stashing, it is worth mentioning that stash is indeed a very nice option:

The command saves your local modifications away and reverts the working directory to match the HEAD commit.

So you can simply

git stash

This is like resetting to HEAD. When being absolutely positively certain that indeed those uncommitted changes are worthless, simply

git stash drop

You can even have multiple stashes etc. as mentioned in the documentation link above.

I would recommend this practice since it puts one in the habit to double-think before resetting without a significant cost.

Solution 3:

You can ignore all uncommitted changes.

git reset --hard HEAD

Solution 4:

If you're really sure that you want to throw away your uncommitted changes (i.e. those that are staged as well as those in your working tree) you can do:

git reset --hard

In general, stashing is often safer

Solution 5:

If you have unstaged file, try:

git checkout -- .

Or

git checkout -- filename