Is there a way to move a repository, and all its tags, to be a subdirectory of another repository in an automated fashion?
For reasons, a project was sp
I think I can answer my own question. Adding --tag-name-filter cat
to the git-filter-branch
call. -- --all
does all the branches and tags at once speeding up the conversion considerably. Here's the full call.
git filter-branch --tree-filter 'move-to-subdir $subdir' --prune-empty --tag-name-filter cat -- --all
With move-to-subdir being a little program I wrote to make the subdirectory and move the files into it.
#!/usr/bin/env perl
use Path::Class;
use autodie;
my $subdir = shift;
mkdir $subdir unless -d $subdir;
my $cwd = dir(".");
my @kids = grep { $_ ne $subdir } $cwd->children;
for my $dir (@kids) {
rename $dir, dir("$subdir/$dir")->cleanup;
}
This information is all in the git-filter-branch man page, but it's kind of obscured.