Say my SVN repository looks like:
project/
trunk/
README
foo/
bar.sh
and I have a local, unversioned directory like so:
svn/
project/
trunk/
README
foo/
hum.sh
if my cwd is svn
and I svn checkout http://...project/
I get the following:
svn: Failed to add directory 'project/trunk': an unversioned directory of the same name already exists
.
Fair enough. So: svn checkout --force http://...project/
does check out the repository, but leaves existing files as they are (and reports an E
for existing).
Is it possible to checkout a repository, treating the repository as the 'preferred' version for any conflicting files? I.e. in the example above, I should end up with:
svn/
project/
trunk/
README
foo/
bar.sh
hum.sh
where trunk/README
and trunk/foo/bar.sh
are the versions from the repository, but trunk/foo/hum.sh
is the local version. I'd expect a subsequent svn status
to only report:
? trunk/foo/hum.sh
UPDATE
Hint: I'm probably approaching this from the wrong 'direction' I'm betting sensible use of cp
having checked out the repository 'to the side' would do what I'm after, but I can't quite get my head around it ...
Yes, you're almost there with your svn checkout --force
. To finish, do a svn revert -R
on it. That'll throw away local modifications (but not delete new files).
edit: If you want to do it with cp
, the -n, --no/clobber
option should do it for you:
$ svn co https://…/FOO their-foo
$ cp -rn my-foo/* their-foo
$ cd their-foo; svn stat
should show only new files.
You can use the svn revert -R
command to recursively restore all files to the repository's version, where one exists. hum.sh
would still be ?
but all other files whether they were locally changed or were E
xisting will be restored to the repository version.
You can also use the svn update --accept theirs-full
option which should also overwrite files marked as existing.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With