Force an SVN checkout command to overwrite current files
Asked Answered
P

5

66

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?

Pagination answered 23/11, 2008 at 13:10 Comment(1)
the title is misleading, should be checkout command, not update commandCounterword
S
53

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

Selves answered 23/11, 2008 at 13:27 Comment(6)
My version of SVN (1.3.1) doesn't seem to have a --force option. When was this added?Pagination
1.4, I think, though I'm sure you'll be as good at checking the release notes as I would... Is there are reason why you're so far behind? The SVN project is very well run with respect to backwards compatibility, so there is little reason to fear upgrades.Selves
Yeah - hosted server is running Ubuntu 6.0.6; which has svn 1.3 as the standard install. ThanksPagination
This option was added in Subversion 1.5. It also added --accept theirs-full if you want to force updating on conflicts. (As you might want to on build servers)Michigan
Note, this will only work when no .svn directories are present.Streamliner
svn help checkout merely says --force : force operation to run which is a useless as help gets alas. If that permits overwrite of files in the target folder, then that is what the help should say.Alcaraz
J
64

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.

Jennine answered 10/8, 2009 at 15:57 Comment(0)
S
53

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

Selves answered 23/11, 2008 at 13:27 Comment(6)
My version of SVN (1.3.1) doesn't seem to have a --force option. When was this added?Pagination
1.4, I think, though I'm sure you'll be as good at checking the release notes as I would... Is there are reason why you're so far behind? The SVN project is very well run with respect to backwards compatibility, so there is little reason to fear upgrades.Selves
Yeah - hosted server is running Ubuntu 6.0.6; which has svn 1.3 as the standard install. ThanksPagination
This option was added in Subversion 1.5. It also added --accept theirs-full if you want to force updating on conflicts. (As you might want to on build servers)Michigan
Note, this will only work when no .svn directories are present.Streamliner
svn help checkout merely says --force : force operation to run which is a useless as help gets alas. If that permits overwrite of files in the target folder, then that is what the help should say.Alcaraz
O
9

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?

Olympus answered 9/7, 2009 at 12:18 Comment(0)
D
5

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.

Disoblige answered 18/4, 2012 at 13:13 Comment(0)
A
3

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.

Amorette answered 23/11, 2008 at 13:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.