简体   繁体   English

如何在Git / SVN中合并多个文件的历史记录

[英]How to merge multiple files' history in Git/SVN

I am migrating an old repository from SVN to Git. 我正在将旧存储库从SVN迁移到Git。 This repository contains a handful of files, but for historical reasons these exist within a subdirectory for each month. 该存储库包含少量文件,但是由于历史原因,这些文件每个月都存在于子目录中。 For example: 例如:

Nominal files 标称文件

a.txt
b.txt
c.txt

Actual layout 实际布局

/
|-201601
|  |- a.txt
|  |- b.txt
|  |- c.txt
|-201602
|  |- a.txt
|  |- b.txt
|  |- c.txt
|  
...
|-201807
   |- a.txt
   |- b.txt
   |- c.txt

(note no files at top level)

As part of the migration I'm going to remove these dated subdirectories, and we'll just have top-level files. 作为迁移的一部分,我将删除这些过时的子目录,而我们将只有顶级文件。 However, I would ideally like to merge the history from all "versions" of the file into one - that is, running git log a.txt in the new repo would show all the changes that were previously committed to 201807/a.txt , 201806/a.txt , etc. 但是,理想情况下,我希望将文件的所有“版本”中的历史记录合并为一个-也就是说,在新存储库中运行git log a.txt将会显示以前提交给201807/a.txt所有更改, 201806/a.txt

Is there a Git command (or set of commands) that will let me merge the histories/commit from multiple files into a single file? 是否有一个Git命令(或命令集)可以让我将多个文件的历史记录/提交合并到一个文件中?

(If this is easier in Subversion, that's an option too; I can modify the old repostory before importing into Git.) (如果这在Subversion中比较容易,那也是一个选择;我可以在导入Git之前修改旧的记录。)

First, regarding an import from SVN to Git, the tool to use is SubGit (free for a one-time import) 首先,关于从SVN到Git的导入,要使用的工具是SubGit (一次性导入是免费的)

Second, you can consider each date folder as "branches" in SVN (with their own history), and you can follow " Layout Changed over History ", in order to instruct SubGit how to process those folders. 其次,您可以将每个日期文件夹视为SVN中的“分支”(具有自己的历史记录),并且可以遵循“ 布局更改为历史记录 ”,以指示SubGit如何处理这些文件夹。
If this is not applicable here (because the link I mention is for one branch which is renamed in its SVN history), then you would need to map each folder/branch to a Git branch. 如果这在这里不适用(因为我提到的链接是针对一个分支的,该分支在其SVN历史记录中已重命名),则您需要将每个文件夹/分支映射到Git分支。

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

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