Assigning Git History to an SVN Branch

Situation
I have Git repo and SVN repo that contain the same source code but different commit history. There are a lot of small comments with comments in the Git repository ... while SVN repo has some huge commits with comments like “A lot of things”. Both series of commits follow the same changes as in the code, and are approximately equivalent.

Desired Result
I would like to switch to using Git-SVN without losing the detailed history from the current Git repository. This should be done by “transplanting” the story from the Git repository to the project's SVN branch (branched from the point where I really started using Git).

Why would you do this? (Story)
Some time ago I started playing with Git. I started by creating a Git repository in a project that I had under the control of SVN. With a little configuration, I had both Git and SVN working in parallel in the same source code.

It was a great way for me to learn and play with Git, while having an SVN security net. This is mainly a sandbox with real data. I did not have time to really learn Git, but I really wanted to work with it. It was a really good way to learn Git for me.

First, after making some changes, I have to pass SVN and then to Git ... then play with Git, knowing that my changes were safe in SVN. Soon I committed more often than Git than SVN ... Now, SVN commits have fallen into annoying work, which I have to do sometimes.

Having learned the difference between git revert and svn revert , I was VERY glad that I registered for the SVN repo. I almost lost a few weeks of work, believing that they work the same way.

Now I know the fame of Git-SVN, and I enjoy using it in several other projects. I was fully aware that when I started, I could lose my Git relay and have to install a new one “correctly” using git-svn init ... but, playing with Git for a while, I'm sure there is some way to hack the story Git on SVN.

+6
git svn git-svn
source share
6 answers

It can be hard to do what you want. You can import the git repository into svn through something like this: http://code.google.com/p/support/wiki/ImportingFromGit , but I think you will have conflicts. You can simply restore your SVN repo from scratch based on your git repository.

In the future, it would probably be easier to just use git as an SVN client:

 git-svn clone path/to/your/svn/repo git-commit -a -m 'my small change' vi some files to change.txt git-commit -a -m 'another small change' git-svn dcommit # sends your little changes as individual svn commits 
+2
source share

It seems like this is NOT possible. Although it is possible that the current git repository connected to the current svn repo, it is not possible to reproduce the git repo history in the svn repository.

The main problem I ran into was to get git-svn to “commit” to one svn commit. The answer to this problem seems to be git-svn set-tree . This blog post was most helpful:
http://www.reonsoft.com/~john/blog/2008/06/05/git-first-git-svn-later/

This is how much I can try to save the history in svn:

 git branch svn-reconsile HASH_OF_SECOND_COMMIT git checkout -f svn-reconsile git svn init file://path/to/repos/myproject/branches/git-import git svn fetch git svn set-tree HASH_OF_SECOND_COMMIT git rebase git-svn git merge master git svn dcommit 

The problem is that git svn dcommit will only do one revision in svn ... not for every commit in the master branch .... therefore history is compressed in svn.

So, the easiest way is to simply start start git-svn with set-tree and make sure that the story is still in git, even if it is not in svn. This can be done as follows:

 git svn init file://path/to/repos/myproject/branches/git-import git svn fetch git svn set-tree HASH_OF_MOST_RECENT_COMMIT git rebase git-svn 

If anyone knows how to get around the crush problem (I tried --no-squash ), --no-squash comment! In leu of smart comments, I just agree to keep the git history and vaccination up to the latest svn version using the second piece of code above.

+2
source share

I think this should be possible in one of two ways ... Now I will talk about them and try to present them later, if I can figure them out. If someone can figure out how to publish the part or find out why the part will not work ... comment!

1 - In place using git-svn
(The following are pseudo-commands. THEY ARE NOT REAL - DO NOT USE THEM)

 rm .svn (configure git-svn '/myproject/branch/git-remerge') git svn sync_versions --svn_revision=123 --hash=ad346f221455 git svn dcommit 

2 - Using a separate git-svn repository as a proxy
(The following are pseudo-commands. THEY ARE NOT REAL - DON'T USE THEM)

 mkdir ../svn_proxy cd ../svn_proxy git svn init git checkout hash_of_svn_branch_point git pull ../messy_repo 
+1
source share

You can check the tailor . I used it to convert the git repository to svn so that my work could be posted on our company svn server. It is quite flexible, so it can do what you need.

+1
source share

From the git svn repository you are trying to go to, follow these steps:

 git remote add old-repo <path-to-old-repo> git fetch old-repo # to browse and figure out the hashes, if that helps gitk --all & # for each branch you want to graft git rebase --onto <new git svn branch base> <old-repo branch base> <old-repo branch tip> # when done git remote rm old-repo 

For your information, you should also be able to do the same using git format-patch and git am, but git rebase should be more friendly.

0
source share

I did a ton of work on this, dealing with git stories for memcached from a few things. Many of the things I worked on verified that everyone was duly hired.

I created a tool to create a report showing exactly where the trees converge regardless of commit hashes, git stories, authors, commiters, etc. .... Take a look at this sample report , which we used to see where two unrelated repositories converge containing the same information.

From there, I just did a lot of manual vaccination and filter-branch after many google searches and mailing lists to find out who these people who made the changes really were.

0
source share

All Articles