5

We are testing out using git as a repository system instead of our normal svn. There is one svn repository that we always need. In svn we link this repository with svn propset as a svn:externals. This ensures there is really only one global copy of that particular, heavily used, repository.

Now that we have git repositories, I would like to link the SVN repository to it in essentially the same way as one can with svn:externals. I have somewhat succeeded in doing this. I am new to git, please excuse any ignorance.

In the pure git repo (which I clone via git clone gitmaster@address.org:mygitrepo) I used:

git svn clone svn+ssh://svnowner@hostname.org/path/to/mysvnrepo mysvnrepo

to get a copy of the other svn repository. This works great, I can get new revisions to the SVN repo via git svn rebase in the mysvnrepo directory and commit changes via git svn dcommit.

To combine this to the main git repository I used:

git add mysvnrepo
git commit mysvnrepo
git push

The issue I am having is if I now clone the git repo somewhere else (again with git clone gitmaster@address.org:mygitrepo), while I get the mysvnrepo directory with all the files, I cannot interact with the SVN repo. I get the error: "Unable to determine upstream SVN information from working tree history" after git svn rebase. Possibly related, there is no .git folder in the mysvnrepo directory when I clone it elsewhere (this is where the svn info is stored in the original repo).

I have searched this problem out a bit but all references to it seems to get problems getting the svn repo to work in the first place, whereas my problem is getting it to work for another user.

Perhaps my problem is how to successful add/commit/push the svn repo to the git repo? i.e. is: git add mysvnrepo; git commit mysvnrepot; git push; the correct way to do this?

Edit: improved to give more context

  • How do you clone the repository? By using `git clone` or by checking it out from SVN or …? – siegi Oct 17 '12 at 21:41
  • do you mean the git repository I'm working in? for both the original git repository and the one for the other user I use `git clone gitmaster@address.org:mygitrepo` – Evan O'Connor Oct 17 '12 at 21:49

1 Answers1

2

What it looks like you're trying to do is include one git repository inside another, like you would with svn:externals. It just happens to be that the included repository was created with git svn; that won't really have an effect on how you include that repository inside another.

You'll need to make the git repository that you want to include in the other publicly available somewhere. You can then include it either using either git submodule or git subtree. Neither work exactly like svn:externals; git subtree might be more beginner friendly for other users of the git repository, however.

Depending on what language you're using and what your software is, you could also consider simply making a separate git repository for the heavily used repository, and building that as its own standalone library, jar file, or what have you.

The above only works well if you're planning on switching over to git fully. If some of your team is going to keep working in SVN for a while, git substree or git submodule won't work for you.

Instead, have a look at this question for simulating svn:externals with git svn.

To set everyone up for git use, follow the last example under "Basic Examples" in the git svn man page. Everyone will be able to git clone then run a few commands locally, instead of doing a full git svn clone.

Community
  • 1
  • 1
jbowes
  • 4,062
  • 22
  • 38
  • the issue is I want people to be able to commit back to the svn repository from the git repository using `git svn dcommit`. Making a global git repository for the same purpose would work, but it would be separate from the svn repository; this is undesirable. One solution is to make each person manually git svn clone the svn repository, then they should be able to commit (like I can when I clone it) – Evan O'Connor Oct 18 '12 at 00:39
  • I've updated my answer to include some details about what you can do in that setup. A slow/partial migration from SVN to git with svn:externals is a bit awkward. Hopefully it won't scare you or your team away; git really is wonderful once you are used to it. – jbowes Oct 18 '12 at 10:50