Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to commit to different svn branch without switching

Tags:

branch

commit

svn

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

like image 588
Ankur Bajaj Avatar asked Nov 30 '12 11:11

Ankur Bajaj


1 Answers

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.

like image 106
David W. Avatar answered Sep 29 '22 12:09

David W.