简体   繁体   English

从SVN导入到Git时保留移动文件的历史记录

[英]Retain history of moved file when importing from SVN to Git

A question to Git gurus. 给Git专家的问题。 I am facing the following problem: I need to import a project to Git from SVN with history. 我面临以下问题:我需要将具有历史记录的项目从SVN导入到Git。 The way I do it: git svn clone " http://server/trunk/path/to/my/project ". 我这样做的方式:git svn clone“ http:// server / trunk / path / to / my / project ”。 The history is being imported fine...till the point that particular file was moved to its current location from another location. 可以很好地导入历史记录...直到将特定文件从另一个位置移至其当前位置为止。 Of course if I use url which is higher, eg includes both old and new location, I can track it using history of the old parent folder. 当然,如果我使用较高的url,例如同时包含新旧位置,则可以使用旧父文件夹的历史记录来跟踪它。 The problem is that I can't import the project with old file location as it is not in my ownership. 问题是我无法导入具有旧文件位置的项目,因为它不是我的所有权。 Is there a way to retain the history before the point a file was moved while importing only the project with file's new location? 在仅导入具有文件新位置的项目时,是否可以在移动文件之前保留历史记录?

For a one time import, you could give SubGit a try . 对于一次导入,您可以尝试SubGit

As show in this thread : 该线程所示

SubGit imports/synchronizes only those branches and tags specified on SVN settings page. SubGit仅导入/同步SVN设置页面上指定的那些分支和标签。

So, in order to keep the history for all the previous locations of your trunk folder, please include all those locations into trunk & branches options just as follows: 因此,为了保留trunk文件夹以前所有位置的历史记录,请将所有这些位置包括在trunkbranches选项中,如下所示:

Subversion URL = http://host/svn/repo

Trunk = dir3:refs/heads/master

Branches = dir2:refs/heads/old_master; dir1:refs/heads/even_older_master; branches/*:refs/heads/*

...

With these settings specified SubGit should be able to join the history for all three locations. 通过指定这些设置,SubGit应该能够加入所有三个位置的历史记录。

That would assume the "other location" is in the same repository though. 但这将假定“其他位置”在同一存储库中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM