What is a working copy and what does "switching" do for me in Tortoise SVN?
Asked Answered
P

5

64

I have a software app and I've hit an important milestone, version 2.0.

I decided I want to tag this version as "Version-2.0" so I have named this snapshot. I also created a "Version-2.0" branch in case I need to fix anything and merge it back into my trunk.

After reading through the Tortoise SVN help file, it informs me that I can switch my "working copy" to a newly created branch.

What does this mean?

Presently, I have:

/Project/Trunk/
/Project/Tags/
/Project/Branches/

All checked out. So what would be the point of "switching"? Currently, I just go to my /trunk folder and do my work. And when I made my tag and branch, it created folders in my /Tags/ and /Branches/ folder after I did an update.

Why wouldn't I just go to /Branches/Experiemental-v3.0/ and do my work there if I wanted to?

Can someone explain the concept of "Working Copy" and "Switching" to me? What am I missing? Do people generally not have the whole repository checked out, is that it?

Pseudohemophilia answered 24/2, 2009 at 10:19 Comment(0)
S
44

A working copy is the copy you have checked out to your working area. It doesn't matter if it is a branch or from the trunk. It's what you are working on.

You can switch between branches (or more correctly copies) of the same parent with svn switch. This will basically say, what's different between the current working copy and the branch I am switch to. It then performs an update on your current working copy to the revision of branch you switch to.

So working copy is your checkout, however it was obtained.

Switching is just changing the branch your working copy commits to. Think of it like changing the pointer in the repository where your commits will go. With the aid of acquiring any differences from the branch to your work area.

Sudanic answered 24/2, 2009 at 10:30 Comment(3)
but this doesnt answer the question, King is asking that do people dont generally have all the folders checkedout? like if I go into the /Branches/Experiemental-v3.0/ folder and do some changes wont the changes be committed to this very folder on a commit? who cares about the working copy and "switched to" directory. What you are saying means that user only has one copy checked out at a time.Ingles
Having all folders checked-out doen't mean you have a replica of svn repo. I can have a folder that was checkedout from a branch, but on committing any changes here, I can submit the commits to a different branch if I had made a svn switch.Metabolize
I suggest not to be afraid of working the way you are, and have all your branches checked out on your local machine. That's how we have worked for about 5+ years and it makes life simpler. There are benefits to using the switch thing and just working on one checked out branch, however I wanted to contribute that it's totally fine not to, and have the whole lot checked out, and that works fine for us.Explosion
B
32

It's generally unnecessary to have the whole repository checked out. Branches and tags in subversion are intended to be cheap - ie, they don't create copies of identical files, just reference them. When you've got the whole repository checked out, when anyone branches or tags for any reason, it's suddenly multiplying the space used on your local hard drive.

You can have as many parts of the repository checked out as you need to. So you could have a folder called 'trunk' which is a working copy of just the trunk, another 'version2' which would be a working copy of your branch. This way, any additional tags which are created don't get checked out.

Or you can have one checkout called 'project', and if it's originally pointing to trunk, you can switch it to one of the branches or tags - it's a way of re-using the original checkout so that you don't have to get everything all over again.

It can be quite useful to do this you're working on trunk and suddenly realise you need to commit your changes to a branch - perhaps because they got too experimental. To do this, branch from your working copy, switch to the new branch then commit and your changes will go to the branch rather than trunk.

Bratcher answered 24/2, 2009 at 10:35 Comment(1)
IMHO this should be the accepted answer. It is way better than the currently accepted one, as this one actually addresses the question.Helles
R
6

Working copy is your copy of the code, that you have checked out. Normally, you'd check out just /Project/trunk/, not the whole structure of the repository. Switching is changing your working copy's root. The way you work with SVN is not how it should be done.

Riot answered 24/2, 2009 at 10:28 Comment(0)
I
3

Your working copy is any folder on your hard drive that you've used to check out a project from subbversion. You can "switch" to a different project for that working copy, so that the versioned contents will resemble the contents of that other project.

This is useful to switch from trunk to branch, without having to check out a new copy. It can for example save you some build time, since the unversioned files (your compiled objects, libraries, executables) are not removed or changed.

Dave

Irregularity answered 24/2, 2009 at 10:26 Comment(0)
L
2

You have checked out the whole project tree - this is probably not what you want. For the trunk work, check out a copy rooted at 'trunk', not from the project root. Similarly, for branch work check out only the branch you want.

Lorentz answered 24/2, 2009 at 10:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.