Reputation: 31
I am confused in the concept of switching (using tortoise svn). We are a team of 3 developers and I am Dev2 here.
Firstly, I tried switching using following steps (lets say, currently working on trunk and want to start work in branches v1.0)
Please let me know if I am doing something wrong in above?
But, after that I skipped the switching and then our working gives us following output:
All is working fine without switching then what is the concept of switching?
Also, what will happen if I have uncommitted files in trunk while switching?
Upvotes: 3
Views: 5683
Reputation: 29265
svn switch should just update your local checkout to point to a new location on the server. e.g. if someone has moved folders around in the repository.
Any uncommitted files should be fine - a switch is just a change to the local file system. After the switch when you view diffs or similar, it will be pointing to the new repository.
Upvotes: 2
Reputation: 107040
Imagine if you were working on trunk, and suddenly realized you should have been working on branch 2.3. You could checkout branch 2.3, but you'll lose all of your work. You could try duplicating it, but that could take a long time.
Switching allows you to switch the base of your local copy without losing any of your work. Files you modified will still contain your modifications. Files you added will still be added. Files you deleted will still be deleted.
$ svn co $REPO/trunk/proj1
[...work...work...work...] #Whoops! Should have been on Release 2.3 branch!
# svn switch $REPO/branches/2.3/proj1
[...work...work...work...] #Everything is fine and dandy!
Some people use switch to switch their working copy without having to do another checkout. For example, I finish my work on proj1
, and now I have some work on the Release 2.3 branch. I simply switch to that branch and save time because I don't have to redownload everything. Plus , I save space!
I highly discourage that thinking because you can easily get confused what your working directory is representing. I've seen some convoluted prompts to extract the branch information and display it in the prompt. However, I name my checkout after my project and branch (or trunk) and I use a separate working directory for each and every project.
Speed shouldn't be an issue. It takes five to ten minutes to do a checkout of a really big Subversion project -- just enough time to get a cup of coffee. Nor, in this era of gigabyte disk sizes, should space be a premium. Using svn switch
should not be a common occurrence.
At one time, you sometimes switched if the server that hosted your repository changed. However, there's now a special svn relocate
command just for that purpose:
$ svn co svn://repo/proj1 # We were using svnserve
$ svn relocate svn://repo http://repo/svn #Now we're using Apache https
$ svn relocate http://repo/svn/proj1 #Alternative to the above.
Upvotes: 3