I cloned a git repo and then started playing around in its master branch. After a while, I want to ignore the changes I just made (without committing them), and switch to a diff
You can discard changes you made in a specific file:
git checkout somefile.txt
And then jump smoothly to the branch:
git checkout gh-pages
Blockquote Option 2 did not work for me, it just repeats the error.
The same for me. After git reset --hard + git checkout I was still getting the same error.
I have fix it by adding --force on second command, right after hard reset.
git reset --hard
git checkout -f <branch name>
You can ignore all uncommitted changes.
git reset --hard HEAD
git add -A git stash
this will clear all the changes you made (Only those that are not commited)
Option 1
git checkout -f gh-pages
Option 2
git reset --hard # beware: don't make that a habit
git checkout gh-pages
If you have unstaged file, try:
git checkout -- .
Or
git checkout -- filename