8

I am working on a code usually in trunk but due to recent changes I had to switch my workspace to a branch.

Is it possible to commit any change in the trunk while working in a branch without actually switching the project to trunk

I basically want to commit changes in both trunk and branch without switching back and forth again and again

3 Answers 3

7

The short answer: No

This is why God created svn switch in the first place. It allows you to change your underlying branch of your working directory without losing your work.

Think of it this way: How many times has a developer broke something because they've said to themselves "Hey, I don't have to test this. It's a minor change"?

Even if Subversion allowed you to do what you want, it would still be a bad idea. You'd basically be making changes in a codebase with no real way of making sure they work in the first place. This is why Subversion requires you to have a working directory before you can make changes*. How would you test your changes?

If you don't want to use svn switch because you don't want to lose your work, you could do the following:

  • Copy your entire working directory to another location, then use svn switch on one to make that trunk.
  • Finish your work on your branch. Commit the changes and note the revision number. Now, either do a svn co or svn switch to get a trunk working copy. Then use svn merge -r to merge your changes into trunk. And, of course, test your changes before committing them.

*Subversion does allow mkdir, cp, mv, and rm to work directly upon a URL, but that's mainly to allow you to manipulate branches without having to create a working directory.

1
  • 2
    The short answer: use git
    – Winter
    Jun 26, 2017 at 14:17
0

Check out the trunk in a different folder.
Make your changes in the trunk, and check them in. Then merge them to the branch, and check in the merge.

0

You can't commit to the path outside of WC URL (see svn info WCROOT)

The above rule means - if WC root is at a level, which is common parent of branch and trunk, you can commit into both locations at the same time (branch and trunk will be subdirs inside WC). Common parent is repository-root, in order do not checkout the whole repo, you can play with --depth and --setdepth options of commit/update

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.