问题
For reasons outside of my control, I am working with a repository that has many copies of similar content (a small OS). This means that while the repo size is fairly small, the working directory takes multiple hours to checkout on my system.
The specific tasks being performed is doing a git replace --graft
to concatenate linear histories, then doing git filter-branch --tag-filter cat -- master
to make the change permanent.
My issue is that filter-branch requires a clean working copy (such as generated by git checkout .
or a standard git clone <URL>
). This increases run time to several hours, which is undesirable. Is there a faster way to do this? The actual re-write takes about 30 seconds (all blobs stay the same, just the pointers change).
回答1:
You can create a bare clone and do all filtering there:
git clone --bare source bare
cd bare
git filter-branch master # this is a no-op here, but you get the idea
回答2:
Some ideas.
1) stash your local changes, then pop them back when you are done.
2) create a new clone but use git clone --reference to speed it up.
来源:https://stackoverflow.com/questions/56840780/is-it-possible-to-use-git-filter-branch-with-dirty-working-directory