svntortoisesvnbranch

Commits to SVN branches affects trunk as well


I have a problem that whenever I make a branch using TortoiseSVN from trunk, ALL commits to that branch also show up in my trunk folder after I do an update, and the other way around.

What I do is:

  1. Branch /trunk to /branches/foo using TortoiseSVN. Select "Switch working copy to new branch/tag" option in the dialog.
  2. Run "Update" in order to get the /branches/foo folder into my working copy, which is rooted at the project directory.
  3. Make a change to a file in /branches/foo
  4. Commit this change
  5. Run "Update" - which results in the same file in my working copy's /trunk folder also being updated with the change made in the branch

How do I break this link - or create a branch without it being linked 1:1 with trunk?

The only solution I've found is to copy the whole trunk folder and add every single file again; though this shouldn't be necessary.


Solution

  • From your comments on another answer, it looks like you're using SVN inefficiently. I think this is the root of your problem.

    It sounds like your working copy is the project root, and on your computer you can see every branch, every tag, and also trunk. When you do an update, you update at the root project, and get every change in every branch.

    This is not how SVN was intended to be used.

    The intended use, is to check out one working copy per branch of interest. If you're working on trunk, just check out trunk. If you're working on a feature branch, just check out that branch. You can have multiple working copies for multiple tasks.

    The way you're doing it now, if your project gets very large with a large number of branches and tags, you can take up gigabytes of space when you check out the top-level folder, and every operation will take a very long time to complete.

    Why is this relevant to your problem? Here's what I assume happened:

    1. You branched trunk
    2. You chose to automatically switch your working copy to the branch. This only affected one folder within your working copy. Now your "trunk" folder is not trunk at all, it is actually pointing to your branch. This is obviously going to be confusing later.
    3. You made a change in the "branch" folder and committed it.
    4. You did an "Update" at the top level.
    5. You see your change from the "branch" folder is now in the "trunk" folder as well.

    Now, since you chose to switch your trunk folder, "trunk" on your machine is not pointing to the actual trunk folder in your SVN repository. It is pointing to the branch. This is why you see your change in "trunk" on your machine. If you go into the repository browser, I expect you will NOT see your branch change in trunk. If you "switch" your trunk folder back to trunk, you should see your change disappear from trunk on your machine.

    To avoid this in the future, either: