Tuesday, January 15, 2013

How to move files or directories in Subversion without losing their history

Sometimes we need to move files or directories in our code to a better location.

So far, we were doing it using the Move option in Eclipse.

However, this was wrong, let's see why:

Our code is under Subversion, a version control system.
The way we were moving things was interpreted by Subversion as if we had deleted them and the added new ones. That means that all the history of the moved item is lost and that's not what we intended.

To keep the history of the item when moving it, we must use Subversion to move it.

This is how it's done from the console:
$ svn move source destiny
This command moves the file/directory in your working copy or in the repository keeping its history. It's equivalent to an svn copy followed by svn delete.
The only limitation is that you can only move files within a single repository and the destiny must be a working copy, that is, it must be already included in your repository (to know more).

So from now on, anytime we want to move files or directories in our code to a new location, we'll use svn move.

No comments:

Post a Comment