Thursday, June 9, 2016

combing git repositories with git and svn

 - Combining GIT repositories.
 - Combining GIT repositories and SVN repositories.
 - Keeping git svn working on Mac OS X.

 I have:
 
  git1/stuff/something.c
  git2/other/blah.c
  svn3/project/foo.c
 
In particular, I have three repositories, with no overlap
 in file paths.
 
  I wish to have:
 
   git1/stuff/something.c
   git1/other/blah.c
   git1/project/foo.c
 
  I do NOT wish to push stuff under a new root:
      gitnew/git1/stuff/something.c I do NOT want this.
      gitnew/git2/other/blah.c      I do NOT want this.
      gitnew/svn3/project/foo.c     I do NOT want this.
     
  NOT even picking one of the git repositories
  to house the others in subdirectories:
      git1/stuff/something.c    This is ok.
      git1/git2/other/blah.c    I do NOT want this.
      git1/svn3/project/foo.c   I do NOT want this.

 I will likely have no further use of git2 and svn3.
 This is a one time one direction conversion.
 
  All the repositories are small.
  All have a small number of changelists.
  All have no branches.
  All have just one committer -- me.
  All have little commercial interest.
 
  If I messed up, it would be ok.
  If I lost history, it would be ok.
 
  But ideally, no mess up, and history is preserved.

 I have very little experience with either git or subversion.

 This stuff is mostly documented online by others.

  Some things I did not do, or tried but gave up on:
    http://stackoverflow.com/questions/10014054/git-2-svn-migration (NOT)
   
    http://jasonkarns.com/blog/merge-two-git-repositories-into-one/     (NOT)
      Close, but several of these steps didn't work or weren't needed.
      My git doesn't have a "ci" command.
      read-tree -- more obscure stuff, that I didn't use.

 I tried this briefly, no luck:
   http://www.subgit.com/  (NOT)

 I wanted to use a minimal of commands that made a maximum amount of sense to me.
 I acknowledge that I don't understand git much and haven't use svn much.
 I use Perforce usually.


 The basic steps are:
   convert svn to new temporary git repository
   add new svn-converted git repository as a remote, and pull it
   add "git2" as a remote, and pull it


  You have to say --allow-unrelated-histories.
 
  git svn is typically broken on Mac OS X.
  Some error about perl SVN::Core.pm.
 

  Everyone says to make some links, but that didn't work.
  I only had the developer tool command line tools installed.
  Everyone else uses Xcode.

 
  Solution is to adjust the links, or give in and install Xcode.
 
  I also tried to install svn, but it failed to build because
  something about my httpd. I was going to build that, but, ended up
  just installing Xcode.
 

  I did not use anything related submodules or subtrees or grafting.
  I don't know what they are, so it is nice to not use them.
 

  Github automates the svn to git conversion and that conversion
  worked for me, but I also had done it myself on the command line
  and that worked. I used the local command line conversion instead
  of the github one.
 
 
  Resembling: http://john.albin.net/git/convert-subversion-to-git
 
  I did something like this:
 
  git svn clone [SVN repo URL] gitsvn
  git clone ... git2
  cd git1
  git remote git2 ../git2
  git remote add gitsvn ../gitsvn
  git pull git2 master --allow-unrelated-histories
  git pull gitsvn master --allow-unrelated-histories


It is quite possible I would have been better off with the github
gui for part of this. In particular, it prompts for the author stuff.

No comments:

Post a Comment