私はあなたと同じ問題に直面していることに気づき、これを行うための標準的な方法がないことに気づきました。しかし、周りを見回して、これを行うための戦略を見つけ、それに基づいてPowerShellスクリプトを作成しました。ソースを思い出せない、または私は彼らに信用を与えるでしょう。説明しますが、台本とコメントだけが見やすいです。
このスクリプトを使用することも、Windows / PowerShellを使用していない場合は、それに基づいて作成することもできます。良い点は、サブモジュールごとに個別のgitリポジトリを作成したら、何かが失敗した場合に、新しい「マスター」gitリポジトリを削除し、スクリプトに変更を加えて、スクリプトを再実行するだけです。ローカル。
サブモジュールに別のサブモジュールと同じと呼ばれるフォルダがある場合など、処理されない場合があることに注意してください(したがって、BINというサブモジュールがあり、他のサブモジュールにBINサブフォルダがある場合、失敗します)。また、開始する前に、すべてのサブモジュールのgitリポジトリが最新であることを確認してください。
この要点でスクリプトを確認できます:
要点スクリプト
なんらかの理由で要点がわからなくなった場合は、ここにも追加しました(読みにくくなりますが)
$GitReposLocation = "path\to\individual\git\repos"; #1 git repo for each module (you svn cloned each one using std layout)
$MasterGitRepoLocation = "path\to\masterRepo"; #the path where you want your main repo that contains all the modules
git reset --hard;
write-host Creating folder $MasterGitRepoLocation -foregroundcolor "green";
mkdir $MasterGitRepoLocation;
write-host Moving to folder $MasterGitRepoLocation -foregroundcolor "green";
cd $MasterGitRepoLocation;
write-host Creating Git Repository -foregroundcolor "cyan";
git init;
#this is hacky, but we need to have an initial commit
"" > root;
git add root;
write-host Creating root node -foregroundcolor "cyan";
git commit -m "Initial commit to create parent root.";
#we are going to be moving files around, and don't want to move the files we already got in our MasterRepo root/workspace
$NotMoveThesFiles = @();
dir |%{$NotMoveThesFiles+=@($_.FullName) };
$repos = @();
# you should add a repo here if for some reasong you don't want to process that one.
# $repos+=@("SomeRepo");
dir -Path $GitReposLocation -Directory |Where-object{ $repos -NotContains $_.Name }|%{$repos+=@($_.Name) };
# for-each repo....
$repos|%{
$SubRepoName = $_;
write-host Processing GitRepo $SubRepoName -foregroundcolor "green";
$Remote = "remote"+$SubRepoName;
#add this git repo (of a module) as a remote of our main repo
write-host Adding reference to $SubRepoName as remote repo -foregroundcolor "cyan";
git remote add -f $Remote $GitReposLocation\$SubRepoName;
#Merge that sub repo into the main repo. The only problem? It will copy that repo's workspace
#directly into our main repo Root folder
write-host Merging remote$SubRepoName/master into master -foregroundcolor "cyan";
git merge remote$SubRepoName/master;
#so now we are going to create a folder with the name of this module (subRepo)
#and move everything that is in the Master's root folder to that folder, except of course
#things that we already had in the root folder before the merge. (in the NotMoveTheseFiles array)
write-host Moving files got from $SubRepoName to a subdir called $SubRepoName -foregroundcolor "green";
#create folder folr the module
mkdir $SubRepoName;
#add these new folde to the list of things we don't want to move into it.
$NotMoveThesFiles+=@($SubRepoName);
#copy all files not in the NotMoveTheseFiles array into the newly created folder.
dir |where-object {$NotMoveThesFiles -NotContains $_} |%{git mv $_ $SubRepoName};
#commit the change where we moved all these files around.
$CommitMessage = "Moving files got from " + $SubRepoName + " to a subdir called $SubRepoName"
git commit -m $CommitMessage;
}