I get:
$ git checkout mybranch
error: Your local changes to the following files would be overwritten by checkout:
.idea/workspace.xml
Please, commit your changes or stash them before you can switch branches.
Aborting
But .idea/
is already in my .gitignore
. If I do git status
, there is also no changes showing up.
Please advice.
UPDATE:
Thanks for the advice. I wish I could go to mybranch
and check, but I couldn't, because it wouldn't allow me to switch! Provided that it is the correct behaviour to ignore .idea/
(they are project config files from IDE), what should I do now?
My goal is to go to mybranch
and merge it with master
. You can think of mybranch
as a production branch and master as dev branch. Now I want to update prod as master is stable enough.
In my case, it was due to my former
git update-index --assume-unchanged <filename>
that was conflicting on that file. Undoing this situation via a
git update-index --no-assume-unchanged <filename>
And committing the resulting new status, everything fixed up.
Update: fix typo in parameter.
Check if .idea/
is also present in the .gitignore
of the branch you are checking out apart from that of the branch you are currently on.
A solution is to just stash the changes made to the .idea/workspace.xml
file, checkout to your mybranch
and then add the .idea/
folder to .gitignore
, switch back to master
branch and then apply the stashed changes, then merge both the branches.
Both answers are correct about the cause. But git stash doesn't work because either it won't stash changes made to workspace.xml which is ignored, or workspace.xml has been changed somewhere else down the tree.
What I did is to git clone the repo to somewhere else, checkout to mybranch, edit gitignore, commit and then merge from master.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With