Reputation: 5949
I am developing a project in git. Someone else has taken a snapshot of my project and continued development in svn. Now I want to merge changes from svn back into git.
Is there an easy way to merge changes from svn into git? The best I can come up with is creating a new git branch and manually adding all of the files in.
My understanding of git-svn is that it creates a new git repo based on the svn repo. The documentation also says "don’t push to a parallel Git repository to collaborate with fellow Git developers at the same time", which sounds exactly like what I want. The only simplification is that I do not need to write anything into svn; changes are moving from svn to git only.
Upvotes: 0
Views: 79
Reputation: 70763
You need to be aware, that using git-svn the history of the svn-branch will most likely not join up with your git history. So here’s what you need to do.
OUR-DIV
for the sha of the version of the last common commit in your git history, THEIR-DIV
for the sha of the version of the last common commit in the imported svn history.git replace $THEIR-DIV $OUR-DIV
(see docu of git replace)svn_branch
Have a look at the new git log
and see whether the result is to your liking. If it is, run:
git filter-branch svn_branch
svn_branch
to your main git repoAfter that, you can not simply import further changes from svn into svn_branch
. If you want to that, you need to delete svn_branch
, import your changes and then start again from step 6. I am not 100% sure that this will absolutely work, though. Handle with caution.
Upvotes: 1
Reputation: 2014
I would avoid any fancy tricks and keep it simple.
Just create a new branch in git. Next, overlay (copy) the files from the svn branch into your git branch. Commit your changes.
I like to use the visual kdiff3 for merging two folders, since I assume you want to cherry pick changes. However, there are lots of great tools for merging two similar folders.
Once the files are overlaid on top of your git files, you have a final chance to review changes before committing. Atlassian Source Tree is a great tool for reviewing changes visually, but again there are lots of great tools out there.
Upvotes: 3