I need some clarification about the behaviour of "svn switch". I'm using SVN version 1.6.5.
From reading the manual, my understanding of the behaviour is that local changes will be preserved. So I would expect a locally-added file to still exist in my working directory after svn switch
.
However, my colleagues and I have seen several instances where new files get deleted by the switch. Unfortunately, we can't figure out how to reproduce this.
Is there some circumstance (either a feature or a known bug) under which svn switch
deletes locally-added files?
Use the "svn switch" command to convert your local "trunk" copy into a copy of this new branch. Your local changes will be preserved.
$ svn delete -m "Deleting file 'yourfile'" \ file:///var/svn/repos/test/yourfile Committed revision 15. Use the --keep-local option to override the default svn delete behavior of also removing the target file that was scheduled for versioned deletion.
A switch moves your working copy through time and space. Because svn switch is essentially a variant of svn update , it shares the same behaviors; any local modifications in your working copy are preserved when new data arrives from the repository. This allows you to perform all sorts of clever tricks.
To add an existing file to a Subversion repository and put it under revision control, change to the directory with its working copy and run the following command: svn add file… Similarly, to add a directory and all files that are in it, type: svn add directory…
I think it's a bad idea to switch, when you have uncommitted changes. First, commit your local changes to a branch with svn cp . <branch URL>
, and then switch. There may be very tricky situations you can get into otherwise.
Imagine, that in a version you're switching to, the files you added locally already exist, and are completely different. Or, what if you added a whole directory of files, which can't be adequately merged with the files in the version you're switching to. Do you really want that one big conflict?
There's "S" state shown by svn status
, meaning that different parts of your source tree have different versions. It happens exactly when SVN is confused with local changes during a switch. It just gets broken in a middle of switch, and then it's a pain in the neck to recover. Happened to me several times. That's why I always make sure, that my working copy has no local modifications before I run svn sw
.
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