[svn] Force an SVN checkout command to overwrite current files

I'm adding an existing site to SVN.

The files already exist on the webserver, and now identical copies (- configuration files) exist in the repository.

I want to convert the webserver directory into an SVN working copy, but when I run:

svn checkout http://path.to/svn/repo/httpdocs .

I get the error:

svn: Failed to add file '': object of the same name already exists

How do I tell SVN to just overwrite those files whose contents are the same?

This question is related to svn

The answer is


Try the --force option. svn help checkout gives the details.


I did not have 1.5 available to me, because I am not in control of the computer. The file that was causing me a problem happened to be a .jar file in the lib directory. Here is what I did to solve the problem:

rm -rf lib
svn up

This builds on Ned's answer. That is: I just removed the sub directory that was causing me a problem rather than the entire repository.


Pull from the repository to a new directory, then rename the old one to old_crufty, and the new one to my_real_webserver_directory, and you're good to go.

If your intention is that every single file is in SVN, then this is a good way to test your theory. If your intention is that some files are not in SVN, then use Brian's copy/paste technique.


This can be done pretty easily. All I did was move the existing directory, not under version control, to a temporary directory. Then I checked out the SVN version to my correct directory name, copied the files from the temporary directory into the SVN directory, and reverted the files in the SVN directory. If that does not make sense there is an example below:

/usr/local/www

mv www temp_www
svn co http://www.yourrepo.com/therepo www
cp -pR ./temp_www/* ./www
svn revert -R ./www/*
svn update

I hope this helps and am not sure why just a simple SVN update did not change the files back?


I did not have 1.5 available to me, because I am not in control of the computer. The file that was causing me a problem happened to be a .jar file in the lib directory. Here is what I did to solve the problem:

rm -rf lib
svn up

This builds on Ned's answer. That is: I just removed the sub directory that was causing me a problem rather than the entire repository.


Pull from the repository to a new directory, then rename the old one to old_crufty, and the new one to my_real_webserver_directory, and you're good to go.

If your intention is that every single file is in SVN, then this is a good way to test your theory. If your intention is that some files are not in SVN, then use Brian's copy/paste technique.


svn checkout --force svn://repo website.dir

then

svn revert -R website.dir

Will check out on top of existing files in website.dir, but not overwrite them. Then the revert will overwrite them. This way you do not need to take the site down to complete it.


Pull from the repository to a new directory, then rename the old one to old_crufty, and the new one to my_real_webserver_directory, and you're good to go.

If your intention is that every single file is in SVN, then this is a good way to test your theory. If your intention is that some files are not in SVN, then use Brian's copy/paste technique.


svn checkout --force svn://repo website.dir

then

svn revert -R website.dir

Will check out on top of existing files in website.dir, but not overwrite them. Then the revert will overwrite them. This way you do not need to take the site down to complete it.


This can be done pretty easily. All I did was move the existing directory, not under version control, to a temporary directory. Then I checked out the SVN version to my correct directory name, copied the files from the temporary directory into the SVN directory, and reverted the files in the SVN directory. If that does not make sense there is an example below:

/usr/local/www

mv www temp_www
svn co http://www.yourrepo.com/therepo www
cp -pR ./temp_www/* ./www
svn revert -R ./www/*
svn update

I hope this helps and am not sure why just a simple SVN update did not change the files back?