svn to git migration保留复制文件的历史记录 [英] svn to git migration keeping history of copied file

查看:220
本文介绍了svn to git migration保留复制文件的历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图将svn项目迁移到git中,并且我无法迁移已在svn存储库中复制的文件的所有历史记录。

I'm trying to migrate svn project into git, and I don't manage to migrate the whole history of files that have been copied inside my svn repository.

我设法通过以下步骤重现错误:

I managed to reproduce the error I have with the following steps :

# 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历史记录,我只会看到:

Now if I get the git history of original.txt I only see :

> git log
author: (no author) <(no author)@1505a309-be06-4361-bd01-fbca4a25f6d8>
copy original.txt

如果我得到svn历史的sub / original.txt我看到:

Whereas if I get the svn history of sub/original.txt I see :

> 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中看到的相同历史记录?

How can I migrate this folder to git keeping the same history I see in svn?

推荐答案

Git并没有真正跟踪文件重命名或副本。它只是尝试来识别文件是使用基于启发式的方法

Git does not really track file renames or copies. It just tries to recognize whether the file was copied or renamed using heuristic-based approach.

由于在Git中没有真正的重命名跟踪,所以有一个在重命名或复制文件后丢失文件历史记录的可能性。我猜你已经遇到了这个特定场景

Since there is no true rename tracking in Git, there is a chance of losing file history after renaming or copying it. My guess that you've encountered this particular scenario.

这篇关于svn to git migration保留复制文件的历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆