How to replace a directory in a SVN repository without breaking anything
I need to replace a directory in my SVN repository on the production server, but am not sure of the correct way to do this without breaking anything. The directory being replaced is a third-party module revision that has been compl开发者_开发知识库etely restructured, so in order to upgrade cleanly I need to deleted the old directory/files and replace with the new directory and files. When I do this (using svn delete) the working copy becomes obstructed or in a state that prevents me from committing or adding the new, unversioned directory to the working copy. I've tried svn update, svn cleanup, as well as other UI (TortoiseSVN and Cornerstone) fix-it shortcuts, but can't seem to get things re-synced - that is without rolling back to a previous revision or checking out a new copy.
I believe that the target directory on both the local working copy and remote repo have to be deleted, the working copy updated, the new directory added to the working copy and then committed to the repo; but I am unsure of the specifics or any missing steps or subtleties that I may be missing. The module that I am upgrading is pretty vital to the site application, so I need to get this right the first time - as this is being made on the production server - and has to be done quickly. If someone could map the steps out clearly, I would really appreciate it.
To make this easier, you can do it in a way that creates a single "broken" revision where the directory doesn't exist.
svn up
to get your working copy up to datesvn delete <directory>
to get rid of the current directorysvn commit -m 'Deleted old module'
- Copy in the new directory to the working copy
svn add <directory>
to add your new directory structuresvn commit -m 'Added new module'
This question has details about how to use "Vendor Branches", which may prove to be a better solution for your situation.
It is straight-forward to do this using TortoiseSVN's RepoBrowser. Simply delete the old folder then drag and drop the new folder in.
If you really need the directory structure to be updated in a single commit, You might use WinMerge :
- compare the two trees recursively, using a SVN filter to avoid comparing.svn directories
- Remove the files and directories which don't exist in the new structure from your WC
- Add the files and directories which only exist in the new structure to your WC
- Replace all the files which exist in both structure with the new ones in your WC
- commit
精彩评论