svn git迁移保留复制文件的历史
问题描述:
我试图将svn项目迁移到git中,并且我无法迁移已在svn存储库中复制的文件的整个历史记录。svn git迁移保留复制文件的历史
我设法重现我的错误有以下步骤:
# create a test repository
svnadmin create test
# checkout the project and create a file
svn co svn://localhost/test
cd test
touch original.txt
svn add original.txt
svn commit -m "add original.txt"
# add an item in the file's history
echo "change 1" >> original.txt
svn commit -m "change 1 in original.txt"
# create a sub folder
mkdir sub
svn add sub
svn commit -m "add sub"
# cp original to sub
svn copy svn://localhost/test/original.txt svn://localhost/test/sub/
# migrate to git
cd ..
git svn clone svn://localhost/test/sub test-sub
现在,如果我得到original.txt的git的历史,我只看到:
> git log
author: (no author) <(no author)@1505a309-be06-4361-bd01-fbca4a25f6d8>
copy original.txt
而如果我得到我看到:svn sub/original.txt的历史记录:
> svn log
r4 | (pas d'auteur)
copy original.txt
r2 | (pas d'auteur)
change 1 in original.txt
r1 | (pas d'auteur)
add original.txt
如何将此文件夹迁移到git保留我在svn看到的历史也一样吗?
答
Git没有真正跟踪文件重命名或副本。它只是尝试来识别文件是否使用heuristic-based approach复制或重命名。
由于在Git中没有真正的重命名跟踪,所以有一个chance of losing file history after renaming or copying it。我猜你已经遇到过this particular scenario。