Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are "switched files" with regard to SVN/IntelliJ?

I have an existing Maven project, which I used to create a new IntelliJ project (the "Import project from external model" option). I changed a few files and committed them.

Then I realized I was on the wrong branch (let's call it wrong). I exited IDEA, used Tortoise SVN to switch to the correct branch (let's call it right), and then re-opened IDEA. Everything seems fine, except that I now have a group in the Local tab of the Changes window called "Switched Files." This "Switched Files" has a subgroup called "branches/wrong" which appears to contain ALL the files in the entire repository! These files do not differ from the ones checked into right, and most of them do not differ from the ones in wrong, either. Yet here they are in my Changes window.

Moreover, these files do not show up in a Tortoise "Commit" window, but they do show up in a Tortoise "Check for modifications" window. But again, these files have not been modified, nor have any of their properties been modified, so far as I can tell.

What are "Switched Files" and how do I simply revert everything to the right branch?

like image 772
Neil Traft Avatar asked Oct 21 '11 18:10

Neil Traft


2 Answers

I just had a similar issue where after switching branches, one file was marked as "switched" for some reason.

I was able to fix this through IDEA by making sure I didn't any local changes, switching back to the "wrong" branch, then again switching to the "right" branch.

Note that I'm using IDEA to switch, rather than Tortoise.

like image 145
mikhail Avatar answered Oct 28 '22 16:10

mikhail


Apparently this is just a Subversion thing. I was unaware of the concept of "switched" files. You can tell if some of your files are switched by using the command line:

$ svn st
    S  file1.txt
    S  file2.txt

The "switched" files will be marked with an 'S'. If you execute svn info on one of these files, you will see that the URL listed does not match the URL of your current branch. See this SO post for more info.

I still don't know what it means really, or how it got into that state just by doing "Tortoise -> Switch...", but I do know how to fix it:

$ svn switch URL

Where URL is the svn:// URL of the branch that you want to switch to. That should recursively scan all files and put them firmly on the "right" branch.

like image 39
Neil Traft Avatar answered Oct 28 '22 15:10

Neil Traft