0

Okay so here is my issue. My work uses SVN. I want to use Git locally. Seems pretty straightforward with git svn BUT my work threw a little wrench in because they literally use 5 different SVN repo's that go into one complete checkout.

So when I do svn up It literally pulls from 5 different repos. This means that I cannot simply do a git svn clone because each of these 5 repos are needed to create the total application. Now, if I had ANY power to change this I would...but in the mean time would i be able to go into the checked out application and just do a "git init" / "git add ." etc and just trick git into thinking its one giant repo? Then use svn commands to commit when the time comes to commit?

Thanks for your help!

1 Answer 1

1

There's no support in git-svn for doing this. You could write a simple bash script to do the commits/rebasing for you, but honestly I recommend doing it by hand in case something goes wrong while updating or committing to the SVN repos.

When I run into this problem I clone the repositories into one directory and then create symlinks between the main project and the external repositories.

That is, let's say I have the structure:

/main-project
  /external-repo-1
  /external-repo-2
  /external-repo-3
  ...etc

I do something like this:

# Create the unified project directory
mkdir LocalProject
cd LocalProject
# Clone the main project
git svn clone svn+ssh://svnserver/main-project
# Find out where all the external repos are
cd main-project
git svn show-externals
cd -
# Clone the sub-repos
git svn clone svn+ssh://svnserver/external-repo-1
git svn clone svn+ssh://svnserver/external-repo-2
git svn clone svn+ssh://svnserver/external-repo-3
...etc
# Create the symlinks
cd main-project
ln -s ../external-repo-1
ln -s ../external-repo-2
ln -s ../external-repo-3
...etc

WARNING: I think this goes without saying, but make sure you don't commit the symlinks to your repo.

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

3 Comments

The only problem with this is that the repos arent all nicely placed in one folder like that. Each repo has shared directories with other repos and therefore sprinklings of each repo are found everywhere. :\. Personally the ability to rebase the code isn't what im looking for....im just looking to use the local branches and then I wouldn't mind just using the svn commands to move code back.
Unfortunately my experiences with creating a git repo inside of an SVN project checkout have been dismal and normally end up with me migrating my changes to a clean checkout using a visual diff editor like meld. It's just too easy to mess up the SVN metadata. You could try creating a git repo in your SVN checkout and creating .gitignore which ignores .svn directories and then doing svn propset svn:ignore .git to have svn ignore the git repo files. YMMV
In the end there was no way to do it with the code base as it was...however this answer came closest and was well thought out so i will mark it as the answer :) Thanks!

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.