问题
I've been trying to modify a script using git filter-branch that takes a git repository and separates it in multiple new directories by specifying subfolders of this directory. The new directories should only have the commits that modified their corresponding subfolders, hence the use of filter-branch. My goal being to change filter-branch by filter-repo for better performances.
It used to create a new branch $branch then use this command :
git filter-branch -f --prune-empty --tag-name-filter cat --subdirectory-filter $subdir $branch --tags
Followed by this to push the branch to its corresponding repo (which has the same name) as well as the rewritten tags :
git checkout $branch
ssh-agent bash -c "ssh-add ../$privateKeyName; git push $branch $branch:$branchToExtract --tags -f"
($branchToExtract is not important, you may just consider it to be "master")
So, as said before, I've been trying to use filter-repo instead of filter-branch. This is the command I've been using :
git filter-repo -f --prune-empty always --subdirectory-filter $subdir --refs $branch
And it works fine ... Except for one (important) thing : when pushing everything to the new repos, the tags are the same that the main original repo, which means that they have way too much content (and commits) and not what they should have. It's like the tags aren't being rewritten at all. I've been trying a few different things like --tag-rename but to no avail.
Any help as to what I should do or indication about what I may be doing wrong would be really appreciated. Thanks :)
回答1:
As stated by LeGEC, listing the tags in --refs solved the problem. I didn't fully realize how the option works.
To anyone interested, this mean the correct command is
git filter-repo -f --prune-empty always --subdirectory-filter $subdir --refs $branch $(git tag -l)
来源:https://stackoverflow.com/questions/63111136/git-filter-branch-to-filter-repo-tags-not-rewritten