开发者

How to clean up obsolete rewritten commits in git after a git-filter-branch

I needed to remove a couple of obsolete files from the git history, so I followed the approach of using "git filter-branch ..." as suggested in various questions and in the git manual. A开发者_C百科fter running the command, I now see the all rewritten commits in my "git log", so instead of the original 10 commits, I now have around 30 commits (after removing 3 files).

I tried the suggestions provided in various answers to remove the ".git/refs/originals" and then "git reflog expire..." and "git gc --aggressive --prune" etc. but I still have 30 commits. I also tried the suggestion of cloning my repository into a new one, and the new one has 30 commits as well. I also pushed to github and now that has 30 commits.

Is there anything I am missing to get rid of the overwritten commits (without doing a rebase operation). My goal is to only get rid of the "duplicate" commits, not to squash commits.

Thanks!


Exactly what commands did you run? It's probably best to make a fresh clone of this repo and try again. There is a guide on help.github that might help.


You can also try rebase -i --preserve-merges or script git cherry-pick --no-commit to do what you want.

Hope this helps

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜