How to commit existing project to SVN with Eclipse Subclipse?

user1768830 picture user1768830 · Jun 18, 2013 · Viewed 31.8k times · Source

I have an existing Java project in Eclipse:

MyProject/
    src/
        ... all main sources
    test/
        ... all test sources
    build.xml
    ... lots of other stuff

I now want to add this project (commit all of it) to the empty trunk/ of a new SVN repo:

https://svn.example.com/MyProject/
    trunk/
        (Empty)

So that, after the commit, the repo now looks like:

https://svn.example.com/MyProject/
    trunk/
        src/
            ... all main sources
        test/
            ... all test sources
        build.xml
        ... lots of other stuff

I installed the Subclipse plugin.

In Package Explorer, I:

  1. Right-click MyProject/
  2. Team >> Share Project >> SVN >> https://svn.example.com/MyProject
  3. Use specified folder name of "trunk" so that the URL is now https://svn.example.com/MyProject/trunk
  4. Click "Finish"

When I do this, instead of committing all my source code (contained in MyProject) to the trunk/ in the repo, it overwrites (thus a checkout) MyProject/ with an empty directory!

Thus, Share Project seems to be for checking out code from a repo, not committing new code into a repo for the first time!

How do I accomplish such an initial commit with the Subclipse plugin and/or Eclipse's Team features?

Answer

Mark Phippard picture Mark Phippard · Jun 21, 2013

Share Project is the right option. However, you should let it create the trunk folder. What the process will do is run the svn mkdir command to create the trunk folder. It will then checkout that empty folder into your project (which does not impact your content at all). At this point, you now have a working copy which is the critical part. Obviously all of your project content still needs to be added. At this point your content will show as Unversioned. The process will launch the synchronize option to give you a chance to do this, though you can also just do it via the Team > menu option. You need to use Add to Version Control for everything you want to add, and then ultimately commit it. You can also choose to ignore some items if you want to be sure they are never committed.