Moving files to a different directory

ArsDigita : ArsDigita Discussion Forums : CVS for Web Development : One Thread
Notify me of new responses

For we need to rearrange our tree structure moving many files from one directory to another. We don't want to lose the CVS log entries about these files when we move them.

I tried using the instructions at:

but the logs were not maintained after the move.

Anyone know how we can do this?

Thanks Caroline

-- Caroline Meeks, November 29, 2000


I believe this is known as 'repository surgery'. Richard L. suggested finding someone experienced with this procedure to help in the process.

-- Kyle Nicholls, November 29, 2000

For those who can't just call someone, here is the CVS bubbles page I learned the surgical proceedure from:;=287

-- Cynthia Kiser, November 29, 2000

The logs were maintained (if you followed the instructions) but perhaps not in the way you expected.

You need to read the section of the documentation linked to from that FAQ. If you don't understand what each option is doing, why it produces the results it does, and the discussion of pros and cons, you need to read more of the documentation until you understand how the repository works.

Before you do anything in the repository, you need to back up all the files you intend to work with lest you screw up irrepairably.

If you are at all uncomfortable mucking around in the repository, you should enlist the help of an expert. This is delicate, tricky business and should not be undertaken lightly.

-- Kevin Scaldeferri, November 29, 2000

The formally correct way to move anything in the repository is documented in that FAQ: you copy the file to its new location, cvs remove the old one, and cvs add the new one. This preserves the history of the project, i.e. one can recontruct from the repository the exact state of the file tree at any time in the past. The first log entry for the relocated file will say something like "moved from old to new". The final log entry in the old file will also be "moved from old to new". Otherwise the log is preserved.

I suspect that what you mean by "the logs were not maintained" is that the new file does not have the same log entries as the old one. Well, it's not really supposed to if you are using the repository correctly, i.e. as an exact record of how the project evolves.

You can accomplish what you want by simply moving directories or files around inside the repository. The is perfectly safe (aside from screwing up any existing checkouts) as long as you don't care about being able to reproduce the state of the project prior to your changes. By directly altering the repository you make it impossible for CVS to reconstruct the project's history. Sometimes this is OK, but you need to understand what you're sacrificing.

-- Ron Henderson, November 30, 2000

Also read carefully the following statement from the FAQ regarding the use of cvs add/remove to relocate files within the repository:
This is the simplest way to move a file, it is not error-prone, and it preserves the history of what was done. Note that to access the history of the file you must specify the old or the new name, depending on what portion of the history you are accessing. For example, cvs log old will give the log up until the time of the rename.

-- Ron Henderson, November 30, 2000

I've never tried it, but the link that Cynthia posted seems like the best way to me. After doing that, I'd also probably make some non-significant change to each and every file (e.g., add an extra newline to the end), commit, and then add a comment to explaining that I just did a directory re-org and referencing the "surgical procedure" URL.

-- Andrew Piskorski, December 7, 2000