5

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?

Community
  • 1
  • 1
  • 1
    possible duplicate of [Applying commits from one subtree to another in same repo](http://stackoverflow.com/questions/19326233/applying-commits-from-one-subtree-to-another-in-same-repo) – jthill Jan 03 '14 at 03:08
  • @jthill, you are right, that does appear to be a duplicate. I didn't consider those search terms... – Diederick C. Niehorster Jan 04 '14 at 03:14
  • Why would it be, it's not about the SAME repo but a different one. – Andy Oct 28 '15 at 14:29

2 Answers2

9

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!

Community
  • 1
  • 1
0

Yes,you could do it with patches.

  1. Reset last commit by using git reset --soft 'HEAD^'. or if you have 3 commits. just do git reset --soft HEAD~3
  2. Do patches.

I think this answer explain it well.

Community
  • 1
  • 1
johnMa
  • 3,291
  • 24
  • 37