How to keep a branch updated with the trunk or another version on svn

Author: J. Ghattas

Last revision: 2020/02/28, M. McGrath

This text describes how to update your local copy of ORCHIDEE with changes done to the trunk. But it serves just as well for instructions on how to update your local copy of ORCHIDEE with changes done to another branch or personal version of ORCHIDEE on the svn repository. You then need to change the path to the version you want.

The first step is to have access to the branch you want to take the changes from. Ask the administrator for access, including the maintainer of the branch in the CC field of the email so they are aware.

Next, you need to know the svn address of the branch that you want to take changes from. This various from branch to branch. The easiest way to find this out is to go to the "Browse Source" section of the wiki. From there, one can navigate to ORCHIDEE directory of the version you are interested in. For the trunk, this is (though not everyone has access). For TAG 1.9.5 (which everyone should have access to), the website is The part you need to note is what comes after "". This is the identifier that we will pass to svn below, IDENTIFIER. For example, IDENTIFIER=tags/ORCHIDEE_1_9_5, or IDENTIFIER=trunk/ORCHIDEE.


We keep a branch or personal version updated with changes done to the trunk using svn merge by specifying a range of revisions. svn will look at all changes done to the trunk during this range and try to merge them with the local copy:

   svn merge -r x1:x2 svn:// --dry-run

where x1 is first revision and x2 is the last revision of the trunk that you want to consider. All changes from x1 up to x2 will be considered. Note that this always produces the differences between the local version and the differences made between revisions x1 and x2 of the target, which may not be what you expect. For example, the following command will show nothing:

   svn merge --dry-run -r 5000:6300 svn://

even though there are surely differences between your version of the code and TAG 1.9.5. This is because no differences to TAG 1.9.5 were made between revisions 5000 and 6300, and so svn has nothing to compare your code to.

The first time you use the command, add --dry-run to only show what the command will do. If everything looks good, execute the real command:

   svn merge -r x1:x2 svn://

When executing the real command (without --dry-run) some files might be in conflict. For those case, use option report (on French systems) or postpone (on English both cases, the action is to type "p") and resolve the conflicts afterwards. When all conflicts are resolved you can commit the modified version to the branch.

Note that SVN will consider as conflicts lines where modifications have been done both in the branch and in the trunk. But there can be other conflicts which are not discovered by SVN. Testing of the new version is always needed before commiting.


First extract the branch you want to update to a local directory. Make sure you have the latest revision and that no local changes are done in the folder. Use the following or use modipsl:

svn co svn:// ORCHIDEE

The first time you update the branch, the first revision x1 corresponds to the revision where the branch was copied from the trunk. x2 is always the latest revision on the trunk. For example, if your branch was copied from the trunk at revision 1042 and now the latest revision on the trunk is 1392, do the following:

svn merge -r 1042:1392 svn:// --dry-run
svn merge -r 1042:1392 svn://

You'll probably have some files with conflicts. Use options report/postpone(p) to resolve them one by one afterwards. An example of a conflict is

<<<<<<< .mine
Grilled Chicken
>>>>>>> .r2

The lines before "======" are in the local file, and those below are in the trunk. svn does not know which of these is correct, so you have to tell it, erasing the "<<<<<", "====", and ">>>>>" lines.

When all conflicts are resolved, test the new version and then you can commit the changes to the SVN repository:

svn ci

Add a clear log message. For example: Updated branch with changes done on the trunk from revision 1042 up to revision 1392.

Now your branch is up-to-date with the trunk. But later on when there have been more changes done to the trunk you'll need to update again. This time, start from the revision after the last revision when the branch was updated, x1 becomes in this case 1393. Suppose that the current revision on the trunk is now 1400. Do the following:

svn merge -r 1393:1400 svn:// --dry-run
svn merge -r 1393:1400 svn://

Resolve conflicts, test, and commit.

Last modified 4 years ago Last modified on 2020-02-28T15:19:49+01:00