Mi sono ritrovato nello stesso problema con te e ho scoperto che non esiste un modo standard per farlo. Tuttavia, guardandomi attorno ho scoperto una strategia per aiutare a farlo, e ho creato uno script di power shell basato su questo. Non riesco a ricordare la fonte, o darei loro credito. Lo spiegherei, ma è più facile vedere solo la sceneggiatura e i commenti.
È possibile utilizzare questo script o, se non si utilizza Windows/PowerShell, eseguire su basato su di esso. La cosa buona è che una volta che hai i tuoi repository git individuali per ogni sottomodulo, se qualcosa fallisce, è veramente veloce/facile eliminare semplicemente il nuovo repo "master" git, apportare modifiche allo script ed eseguirlo di nuovo, dato che è tutto Locale.
Attenzione, ci sono alcuni casi che non vengono gestiti, come quando un sottomodulo ha una cartella che è chiamata la stessa di un altro sottomodulo (quindi se si ha un sottomodulo chiamato BIN e poi gli altri sub moduli hanno sub una sottocartella BIN, fallirà). Assicurati inoltre che tutti i tuoi repository git sub siano aggiornati prima di iniziare!
È possibile controllare lo script in questo gist: Gist Script
se per qualche motivo il succo è giù, ho aggiunto anche qui (anche se molto meno leggibile)
$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 |%{[email protected]($_.FullName) };
$repos = @();
# you should add a repo here if for some reasong you don't want to process that one.
# [email protected]("SomeRepo");
dir -Path $GitReposLocation -Directory |Where-object{ $repos -NotContains $_.Name }|%{[email protected]($_.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.
[email protected]($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;
}
fonte
2014-03-22 02:04:18
Looks come un duplicato di http://stackoverflow.com/questions/279144/clone-multiple-svn-projects-with-git-svn – Wernight
Questa altra domanda non riguarda l'unione dei progetti svn nello stesso repository git. –