views:

1356

answers:

3

I work with software that is kept in svn for version control. I would like to use git (git-svn) however the software requires lots of setup and configuration before it can be used. There are tools that take care of all of the setup, including checking out all the code via svn.

All the documentation for git-svn (I've been able to find) requires a fresh checkout, using git-svn.

Is there a way to convert an existing svn checkout so it can use git-svn?

+6  A: 

No. A git-svn clone converts the entire repository into git. SVN checkouts do not have the entire repository and so cannot be cloned from. This is the primary advantage of switching from SVN or CVS to a distributed system (like git).

singpolyma
I don't care about all the history though, just the state it is in when it got checked out of svn, and future changes on the svn branch (so what I'd get from calling git-svn rebase)
Jachin
That's not how git works. DVCS is "distributed" because every clone is a full copy of the repository. That's the whole point.
singpolyma
+1  A: 

You could do something like this:

  1. Do a full clone of your SVN tree using git-svn, to a temporary directory. Make sure you use the exact same revision as your existing checkout.
  2. Move the ".git" folder from the top level of the git-svn checkout into the top level of the SVN checkout.
  3. Then you'll either need to tell Git to ignore the ".svn" directories, or you can delete them all.
  4. Delete the git-svn checkout.
  5. There, now you can manipulate your existing files with Git and git-svn.
  6. Do a "git status" and hope that it says there are no changes.
andy
I haven't got it completely working how I want it, but this sort of strategy seems like it will work.
Jachin
Is there any way to accomplish that WITHOUT having access to the svn repo? I have currently no way of accessing the repo, all I have is an untouched working copy at the last revision. I hoped that maybe git svn fetch -r N, with N being the revision of my working copy, might somehow be persuaded to use the working copy's content to fetch the needed information...
Ole
A: 

Since all the history is in the .git directory, copying that from a temporary clone might very well work. It however defeats the purpose of not downloading all the files again. It's better to move the svn working copy aside and do a git-svn clone in the old place.

iwein