Kevin
Kevin

Reputation: 6292

Correct way of importing a project in SVN?

I have a question regarding how to importing a project into a Subversion repository. I found a lot of answers by googling, but I could not understand the logic behind it.

The steps I understand is:

  1. Create a project directory with three sub-directories: branches, tags and trunk.

  2. Place all code under trunk.

  3. Run the command:

    svn import project_dir file:///repository_name/project -m "First Import"

    where the project_dir contains the three sub-directories.

After this, I need to check my code out again to another directory:

  1. svn checkout file:///repository_name/project/trunk new_project_dir

  2. Continue working on the new_project_dir.

It seems to me that we create the project_dir for use only once and ignore it.

My questions are:

  1. After I checkout the code into new_project_dir, is the old project_dir still useful? Or it is simply just to give SVN the layout?

  2. Do we ever need to work on the two other sub-directories: branches and tags on our own (e.g. checkout the contents in there)? or it is simply for SVN internal use? If it is for SVN internal use, why can't SVN create it automatically for us?

Upvotes: 2

Views: 25428

Answers (2)

Attila
Attila

Reputation: 28762

You could create the layout in SVN directly if you wanted; using step 3) in your question makes it easier as it allows all in one go. If you follow it, you do not need that initial folder after the import. In fact, the folder you do the import from is not placed under version control, so changes made there will not make it back to the repository

As for the layout: it is customary to do so, but SVN does not impose a restriction: you could organize your project the way you want. The traditional logic is:

  • trunk denotes the latest known working copy
  • branches have sub folders that denote various development efforts (possibly by separate people) -- e.g. for a particular bug fix. You work on it not afected by changes to the trunk or other branches, then merge your changes to the trunk when you are ready.
  • tags are marked versions of the trunk to denote the state of the trunk at a particular time/stage -- this is to allow easy location of what belongs to the same release, for example, instead of having to remember several version numbers

Upvotes: 4

Agent_L
Agent_L

Reputation: 5421

The old project_dir is just to give SVN the layout. The code is copied into repository, but SVN only READS this dir and files, not touching them. Therefore it's not a "working copy".

After you checkout into new location, it contains the code AND svn metadata which makes the magic happen.

AFAIK the trunk, tags and branches are just a naming convention. SVN does not need them, YOU may need them in the future. If you don't plan branching or tagging, you may import files straight to root.

Upvotes: 1

Related Questions