Category Archives: svn

svn merge a revision on trunk to a branch

Merging a set of files from Trunk to a branch

The scenario is that you have made changes to a selection of files and committed them all in one revision.  You then wish to merge only these changes into a branch (e.g. for release).  How can you grab just your changes and merge these?

  1. Find the revision number on trunk that you want to merge into the branch
  2. Check out the branch to your local machine
  3. cd to the branch directory on your machine
  4. make the call: svn merge -c [revision_number] [trunk directory]
  5. svn merge -c 896929 ../trunk

-c gets the differences between the files in the revision you specify and the one before.  It will then try to merge these changes into the branch.

You can use the –dry-run switch to preview the outcome before going ahead with the merge.


Ignoring files in subversion

Often you find that you have files that are part of your project that do not belong in version control and you just don’t want to be bugged by subversion highlighting the fact that you haven’t checked them in.

There is documentation on how to ignore these files in the svn book but I found that it lacked a small detail.

Ignoring files globally

There are some files you know that you will never want to check into the repository no matter what project you are working on.  Rather than having to mark them to be ignored in every directory of every project that you store in the repo you can instead set a global ignore.

In your subverison client install directory (for unix operation systems it is probably called .subversion) there is a file called config, scroll down to the section marked global-ignores and set the patterns you wish to ignore

global-ignores = *.o *.lo *.la *.al .libs *.so *.so.[0-9]* *.a *.pyc *.pyo
*.rej *~ #*# .#* .*.swp .DS_Store .classpath .settings .project

As you can see, you can use regex to define each pattern. Each pattern is separated by a whitespace.

Setting ignore on a specific directory

N.B. You cannot ignore individual files, you can only set patterns to ignore in a given directory.
First navigate to that directory and issue this command:

svn propedit svn:ignore .

After this you will be presented with a file in which you should type in your pattern(s) to ignore.
It’s pretty simple but I just didn’t spot the fact that you should be putting the patterns in this file rather than specifying the pattern in the svn propedit command itself.

Don’t forget to commit your changes!
Happy ignoring!