Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Attempting to setup an SVN repo in Git

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 [email protected]:mygitrepo) I used:

git svn clone svn+ssh://[email protected]/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 [email protected]: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

like image 952
Evan O'Connor Avatar asked Nov 03 '22 13:11

Evan O'Connor


1 Answers

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.

like image 171
jbowes Avatar answered Nov 07 '22 21:11

jbowes