18

I've created a repo, and then I ran svn import . https://myrepo. It seems to have checked everything in nicely, and I can check it out on my other machine. However, it doesn't seem to create the .svn folder, so I can't run any svn ci commands at a later date.

This creates massive headaches to try and sync up later, because now all my stuff is already in the repo, but it conflicts with the changes I'm trying to commit.

What am I doing wrong?

3
  • 1
    So hang on, am I supposed to import it, cd .., rename it, and then check it out again? Is that the standard/expected workflow? Commented Mar 4, 2010 at 8:35
  • 1
    Repeat after me: "The repository is not a working copy and I shouldn't treat it like one." Commented Mar 4, 2010 at 15:02
  • 4
    @Powerlord: what repository? When you import, the local directory is not the repository, it's just imported as the initial version for the repo. Commented Mar 4, 2010 at 19:03

7 Answers 7

32

I never use import because it's uncomfortable. Import doesn't create .svn directories, you'll have to run an additional checkout of the newly imported directory.

Instead of importing files I first create an empty directory in the repo and check it out into my existing project's directory that I want to "import". Then you can simply run commit and it'll add all files.

Sign up to request clarification or add additional context in comments.

5 Comments

You can check out to an existing folder with all your project files in it, and it won't explode?
exactly. you can checkout an empty directory from the repo into an existing local directory that can already contain files. all it'll do is to create a .svn in the local directory. once the .svn exists, you can run commit to commit all the existing files.
this method has one more advantage that i like about it - before committing you can already define your svn:ignores to exclude certain files. i use that very often. i think you can't do that with import, import always imports everything there is (binaries included), so you'll always have to clean up your dir before the import and you'll have to set the svn:ignores after the checkout and commit again.
One comment - I am not sure if this is hidden with some svn clients, but command line svn requires you to add the files (e.g. svn add *) first and then do the commit
This is a much better solution than svn co --force since --force could change file permissions, while this solution doesn't.
6

Only a working copy will have an .svn folder. Import doesn't create a working copy. (Why not? Well suppose for example you were trying to import from media where you don't have write permissions. In that case if import tried to create a working copy, it would fail). To create a working copy, you must use checkout.

Put another way, import pushes information to the repository. That's all it's intended to do, it has no impact on the original files. Most subversion commands only work in one direction: checkout, export, and update modify files on the local system/working copy. import and commit only update the repository. Aside from [un]lock operations, I can't think of a command which simultaneously impacts both the repository and the working copy.

Comments

2

I wanted to provide an update regarding using TortoiseSVN after an import. TortoiseSVN will now allow you to check-out into a non-empty folder.

Therefore, you can simply check-out into the same folder you used for the import. TortoiseSVN versions all the files inside, detects that they all match, and does not download/overwrite anything. No more having to rename the source folder and then check-out into a new empty folder.

This was tested on Windows 7 using TortoiseSVN version 1.8.0, Build 24401 - 64 Bit , 2013-06-17T18:15:59 (Subversion 1.8.0, -release).

Example:

Folder C:\myfiles has the data.

  1. Import that folder into SVN at http://example.com/svn/myfiles

  2. Check-out http://example.com/svn/myfiles into C:\myfiles.

  3. TortoiseSVN warns that the destination is not empty, click Ok.

TortoiseSVN then places C:\myfiles and its contents (which currently match the repository) under version control, without having to modify/download/replace any files.

1 Comment

Unfortunately the verification of the file seems to take just as long as an actual checkout would :( I think I'll try svn co --force, as suggested by Michael Hackner, next time around and see how that plays out.
1

When you setup a project with subversion, after the initial import of your project, you should check the project out and continue work on the project in the copy that you checked out. I think the problem is that you kept on working on the copy that you checked in.

4 Comments

So it seems. But that doesn't explain why import wouldn't create the .svn folder... is it not logical that you want to keep your import up to date?
This is a good question that I can't answer myself. Maybe people don't always want the imported directories to become a "working copy", even though it still would be nice to have that option. I have to say that I never actually thought too much about it.
The manual explicitly mentions that an import does not convert the original directory tree in a working copy. No explanation about the why though. svnbook.red-bean.com/en/1.4/svn.tour.importing.html
It should be an option to the import command. It's ridiculous that svn still doesn't offer a clean way to do this.
1

After you've imported, you can run svn checkout --force to convert the imported directory into a working copy.

1 Comment

The problem is, it seems to change a whole lot of permissions on Linux. I usually import the /etc directory on my servers and find that I need to fix a whole lot of permissions after --force checkout.
0

GAHHHHHHHHH... DON'T USE TORTOISE-SVN TO DO THIS - it will wipe out your local directory.
Sooo......... make a zip/copy somewhere else first !.. sigh... (at least I had a previous - old though - zipfile).

Comments

0

Check folder permissions. In my case it worked.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.