告诉git-blame使用导入的历史记录

时间:2013-05-10 00:32:38

标签: git svn blame

我有一个存储库,它是通过从SVN存储库复制文件(而不是历史记录)创建的,自那以后添加了许多更改。

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

问题是当我对文件执行git blame时,它仍然显示每个行都是由git存储库中的初始提交创建的(它复制了SVN中的所有文件),而不是SVN提交这真的很负责任。

有没有办法可以在不重写所有git历史的情况下解决这个问题?

1 个答案:

答案 0 :(得分:1)

您可以从git为初始提交创建replacement ref来创建它 在大多数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创建的。