Git asks me to commit or stash changes on checkout master, even though all changes were committed?

I encountered a similar problem today. git status wasn't listing the files which checkout was complaining about. I did a:

git checkout -- path/to/file

And that undoes any changes to the file.

An even easier way to undo all unstaged changes on current working directory [1]:

git checkout -- .

[1] - Be warned - you will lose any other unstaged changes you were working on (if any). If you don't know what you are doing, then keep a backup of the files you were working on :)


As simple as this:

git stash
git stash pop

The "errors" you see when running git stash aren't anything to be concerned about. It's just git recognizing that the file doesn't have any uncommitted changes.


I had a similar problem on a fresh clone. I just forced the checkout with the --force (-f) flag

git checkout --force some_branch 

Probably not the best way of resolving the issue on a repo that you are making changes to, but in my case I was sure I hadn't made any changes, and just wanted to switch branch.

Tags:

Git