2013-05-10 61 views
1

我有一个存储库,它是通过复制SVN存储库中的文件(而不是历史记录)创建的,自上次添加了许多更改。告诉git-blame使用导入的历史记录

我已经将SVN中的历史转换为git,并将它与git merge -s ours合并。

问题是,当我在文件上做一个git blame时,它仍然显示每一行都是由git仓库中的初始提交(它复制了SVN中的所有文件)创建的,而不是SVN提交,负责。

有没有一种方法可以解决这个问题,而无需重写所有的git历史?

+0

“git-only”历史中有多少次提交?你为什么不想重写?重写可能是最干净的解决方案。 – Chronial 2013-05-10 00:59:55

回答

1

您可以创建初始的一replacement ref从git的承诺,使其 似乎最git的命令,它起源于Git的历史是建立在从SVN进口的历史 。

您可以用下面的命令做到这一点:

git checkout -b temporary <FIRST_GIT_COMMIT> 
# Set parent of next commit to last one from svn, 
# but don't change the working tree or contents of next commit 
git reset --soft <LATEST_SVN_COMMIT> 
# Create a new commit using contents and message of the first git commit 
git commit -C <FIRST_GIT_COMMIT> 
# Tell git to use the newly created commit in place of the original git 
# commit in most cases. 
git replace <FIRST_GIT_COMMIT> HEAD 

但是,更换引用没有得到自动使用遥控器或者推或拉时 标准refspecs转移。相比,可以 手工完成使用:

git push origin 'refs/replace/*:refs/replace/*' 
git pull origin 'refs/replace/*:refs/replace/*' 

它是不可能有改变的历史会自动转移到其他 库不改变的每一个提交ID提交其 最初使用Git创建的。