简体   繁体   中英

How to merge multiple files' history in Git/SVN

I am migrating an old repository from SVN to 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.

Is there a Git command (or set of commands) that will let me merge the histories/commit from multiple files into a single file?

(If this is easier in Subversion, that's an option too; I can modify the old repostory before importing into Git.)

First, regarding an import from SVN to Git, the tool to use is SubGit (free for a one-time import)

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.
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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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