我遇到过类似的问题,需要处理来自基于 SVN 的开发的多个版本。这是我如何处理它的草图:
# checkout the SVN source
$ svn checkout svn://svnversion/trunk
$ cd /into/svn/checkout
$ git init
$ echo ".svn/" > .gitignore
$ git add .gitignore; git commit -m 'Initial .gitignore'
# Now you have a master branch; create your import-svn branch
$ git checkout -b import-svn
# Add *everything* from the SVN checkout
$ git add -A
$ git commit -m 'Initial SVN'
# Now get the GIT developed stuff
$ git checkout -b import-git master
$ git remote add original-git /path/to/git-developed-repository
$ git pull original-git master # or whatever branch your git developers used.
# Now you've got two branches 'import-svn' and 'import-git'; DIFF and MERGE as you please
# You don't need the remote anymore.
$ git remote rm original-git
我认为这是对的。
现在你可以考虑合并。如果您将“import-git”视为首选基线,则类似以下内容将起作用。
$ git checkout -b git-merge-svn import-git
$ git diff --name-status import-svn
$ git merge import-svn
你也可以尝试如下的变基,然后决定你喜欢哪个:
$ git checkout -b git-rebase-svn import-git
$ git rebase import-svn
并比较合并和变基(应该是相同的,但你永远不知道..)
$ git diff git-rebase-svn..git-merge-svn