Reputation: 53
I am new to git and github. I thought I understood the basics. But now I am confused. Because of problems with my computer I changed to another one and did a git clone from github. Then I wanted to switch branches and typeched checkout branch. This way I also did it on the other computer earlier.
"But I got the following error: Your local changes to the following files would be overwritten by checkout:"
MANY FILES
"Please, commit your changes or stash them before you can switch branches."
How can they be changed just after cloning?
Upvotes: 3
Views: 4168
Reputation: 27325
So normally its possible that you have enabled the autoclrf and filemode value for your repository.
This means that he change the line endings when you clone and mark all as modified.
You can check it with git status
. You can't change the branche because there are modified files.
Change some values in your git config if you don't need it:
.git/config:
autoclrf = false;
filemode = false;
When you set the new values you can make a git status again and look wheather there are modified files again. Otherwise you have to commit and push all modified files.
If you don't want the changes you can reset the changes to the last commit.
git reset --hard HEAD^
Or
git checkout .
Upvotes: 3