How do you switch between branches?

Hi All,

After searching the forum it seems that most people use a separate project
for each branch. I wonder what is the "official" way to switch between
branches. Is there some document saying how to create new branches and keep
projects configurations in sync?

In case someone is interested, this is how I switch between branches. There
is one project which includes sources from all branches. The branch I work
in is marked as "source code" in module configuration. The rest of the
branches are marked as "excluded". To switch to another branch I exclude
current branch sources and unexclude sources of another branch. The only
problem is that after switching like this IntelliJ continues to use classes
from the last branch (and sometimes even fails to run project reporting
errors which do not exist) what can be very confusing. Rebuilding the
project solves the problem.


Dima

3 comments
Comment actions Permalink

On 26.12.2009 12:11, Dmitry Kandalov wrote:

Hi All,

>

After searching the forum it seems that most people use a separate project
for each branch.


don't know if it's official way or not:
suppose we are in trunk, - if i want to work with branch now, i commit
trunk changes and than call update project dialog from version control.
there i check "Update/Switch to specific url" and select the branches i
want to switch into. than if i want to switch back to trunk, i commit
branch changes and repeat the process.

0
Comment actions Permalink

I used to work with one file-system location for all branches and used the 'switch branch' feature or project. But I changed my approach to have a dedicated filesystem space for each branch. Reasons:

-I often was confused and it happened that I checked in code-changes to wrong branches (which is evil -> you don't get notified and reverting often is a pain)
-I often mixed up run-configurations (they had different setting-configurations for each branch)
-From filesystem point of view it is much more consistent (I often go to bash command-line to do some actions), the directory structure instantly shows me on which branch I am.

0
Comment actions Permalink

I am with you on the confusion for sure. If I have a projectx I check out its trunk in a folder where all projects are trunks. If I gotta work on branch 2.x of projectx then I simply check it out to a separate workspace folder where all the projects are branches. That in itself helps me a lot. And then I just point intellij and load up the project based on what I need to be working on. Once I am done working in branch as an example, I commit the changes and then I switch to trunk and pull the changes in. I think and I havent done this in a while but you can merge changes quite easily in Intellij especially if you are using svn.

0

Please sign in to leave a comment.