Is it possible to use git filter-branch with dirty working directory?

不问归期 提交于 2021-01-29 17:30:39

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!