Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

replay git commits on repo with different root

Tags:

git

smartgit

I am one of the current maintainers of the FreeGLUT project on sourceforge. This code is stored in an SVN repo, but to stimulate contributions of others, I want to make a git repo available. I already have a git-svn clone of the svn trunk up on github currently at github (made through SmartGit, which is not really compatible with git-svn actually).

I made this by cloning https://svn.code.sf.net/p/freeglut/code/trunk/freeglut. However, I now find that I should have cloned https://svn.code.sf.net/p/freeglut/code and have SmartGit's svn bridge figure out the branches and trunk.

I have made this new correct clone locally. Now the problem: I already have a few commits in my local git repo of the old/wrong clone. I would like to transfer these over to my new repo, but as the root directories on disk are not the same, a simple rebase strategy as outlined here would not work (I think).

I could do it with patches, as git apply has the --directory argument to prefix the paths in the patch files that would make things work, but then I would have to do it commit by commit. At least, I have not found a way to put multiple commits in a single patch file (without squashing) and replay them all on top of my HEAD.

How to I best solve my problem?

like image 809
Diederick C. Niehorster Avatar asked Jan 02 '14 16:01

Diederick C. Niehorster


1 Answers

Ok, it turns out that:

  1. git format-patch can generate a file containing a range of commits, such as a whole branch.
  2. git am with the --directory option can replay the commits contained in the patch file one by one (see here) and commit them for me.

Problem solved!

like image 128
Diederick C. Niehorster Avatar answered Nov 19 '22 15:11

Diederick C. Niehorster