70

I have a SVN structure like this:

/Projects
    /Project1
    /Project2
/someFolder
    /Project3
    /Project4

I would like to move all the projects into the /Projects folder, which means I want to move Projects 3 and 4 from /someFolder into the /projects folder.

The caveat: I'd like to keep the full history. I assume that every client would have to check out the stuff from the new location again, which is fine, but I still wonder what the simplest approach is to move directories without completely destroying the history?

Subversion 1.5 if that matters.

NoDataDumpNoContribution
  • 10,591
  • 9
  • 64
  • 104
Michael Stum
  • 177,530
  • 117
  • 400
  • 535

9 Answers9

58
svn help rename

Moving/renaming in subversion keeps history intact.

Apocalisp
  • 34,834
  • 8
  • 106
  • 155
46
svn move SRC DST
$ svn move -m "Move a file" http://svn.red-bean.com/repos/foo.c http://svn.red-bean.com/repos/bar.c

svn move will keep your history.

faramka
  • 2,164
  • 1
  • 18
  • 21
Geekygecko
  • 3,942
  • 2
  • 25
  • 21
  • Also much faster if done directly on the repo and update working copies after, its slow to do the move on a working copy – Sam Jun 23 '15 at 13:19
22

Tortoise SVN supports 'Right Click' move in the Repo-Browser. When you drag the source file/directory into the destination using 'mouse right click' a context menu will appear. You can select the appropriate menu option for copy/move/move-rename etc. This option will preserve the history as well.

Note: There is a nice fature called 'Repair Move' in Tortoise SVN - by using this feature you can rename the file/directory when you move it. (Refer to Documentation for more details)

thehill
  • 93
  • 11
Abhilash
  • 761
  • 7
  • 8
  • 2
    Wonder why this answer hasn't got more upvotes. It's much easier than tinkering with the command line or repo browser for small movements. – LWChris Aug 22 '16 at 08:49
  • I personally use Total Commander, and there I miss right click move. – Géza Sep 28 '16 at 11:16
5

If you move Project 3 into the project folder using the svn move command the history will be preserved for the Project 3 folder but interestingly the Projects folder will not show the history of Project 3 that was created before Project 3 was moved into Projects.

I find this confusing, I thought a folder would show all history below itself in the hierachy but it seems like this is not the case (just tested this myself)

Simon Byholm
  • 390
  • 3
  • 10
4

You can use the svn copy command. It keeps your history. You just have to deselect the Option "Stop on copy/rename" while showing the Log (Example for Tortoise).

Take a closer look at the Subversion-Book svn copy

binco
  • 1,598
  • 1
  • 12
  • 15
3

Drag-drop it using the repo-browser and rebind your local folder to your SVN server.

2

Moving directories in Subversion doesn't destroy history, AFAIK.

Eli Bendersky
  • 263,248
  • 89
  • 350
  • 412
2

IN order to do that, you'll have to use svn's specific move/rename functions (check TortoiseSVN help if you use this for example). If you move the files by yourself and then commit the changes i'm not sure that history will be kept.

ljubomir
  • 1,495
  • 1
  • 21
  • 40
-2

As far as I know, only Bazaar allow to keep history on directories, espacially when talking about moving directories. SVN allows you to keep history when moving files, but not directories.

gizmo
  • 11,819
  • 6
  • 44
  • 61
  • 9
    SVN and Bazaar track directories. Mercurial, Git, and CVS do not. – Joshua Sep 20 '08 at 16:07
  • I just moved both a file and a directory on SVN. Both have preserved the whole history. I opened them on Repo Browser and used right-click, drag to new location, release, and select "Move and rename item to here". – Enric Naval Dec 31 '21 at 10:52