Can't commit and branch changed to "unknown". Can't create new branch

I don’t know what happened - my current branch changed to “unknown” from “origin/master”. When I try to change it back so I can commit changes, I get the error message “unable to check out when changes re present on your branch. The following files would be overwritten: (list of files)” . There is a button “Stash changes and continue” but when I press it nothing happens.
I tried to create a new branch but had an error message “failed to resolve HEAD as a valid ref.”
How do I solve this problem?

If you’re working under Windows, this problem usually occurs when there are some non-content changes involved — e.g. differences in EOL (LF vs CRLF), changes in files permissions, changes in filenames lettercasing, and the like. These are changes that don’t affect directly the contents, as seen by Git, but some sort of “extra info” that Git handles apart.

I’ve stumbled upon it a number of times, and it seems just impossible to get out of that situation. In reality, stashing is all you need to do. Probably this is due to some limitations on Git for Windows (possibly related to lack of full POSIX compliance).

I’m not sure how the “unknown” branch came into being, but I have a feeling that the other impediments in creating new branches or checking out to another branch are related to the above problem. You’re probably facing two different overlapping problems, the one described above being the blocking problem.

If the problem is indeed this, just stash … then you should be able to switch branches.

I hope it was useful.