Delete git history beyond a certain point #422
Replies: 3 comments 10 replies
-
Here's an approach. It'll be horrendously inefficient, but it (or something like it) should work:
This should edit the commits you want to keep to detach them from the commits you don't, so the commits you want to remove will be unreachable and get pruned. For less horrible inefficiency, you could use the filter-branch Python library to do something similar, but without needing to re-parse the list of commits to keep for every commit that gets processed. Alternatively, you could find the oldest commits you want to keep, and follow the steps in the "Parent rewriting" section of the manual to rewrite them to no longer reference the unwanted parent commits. That's more manual work, but might end up being quicker. In either case, I'm not sure "developers can continue feature work smoothly and without confusion" is likely to be achievable, per the "Discussion" section of the manual. Git deliberately makes it difficult to change or erase history, particularly for codebases that have multiple people working on them. |
Beta Was this translation helpful? Give feedback.
-
Hi, sorry to bother you again. I have the oldest commit I want to keep but it is unclear from "Parent rewriting" section that how am I going to keep branches changed from "oldest commit" time to the "newest commit" time. That was the main problem I wanted to try "git-filter-repo" for. Any ideas? Thanks again. |
Beta Was this translation helpful? Give feedback.
-
Ah, there are two "Parent rewriting" sections, which is probably not helping! The bit I'm talking about is this one: git-filter-repo/Documentation/git-filter-repo.txt Lines 975 to 998 in e7e2452 Essentially, for each of the oldest commits you want to keep, run |
Beta Was this translation helpful? Give feedback.
-
Hi, I want to delete all git history beyond a certain point such that:
git merge-base
) is preserved so that, on the new cleaned repo, developers can continue feature work smoothly and without confusion.Is that possible with git-filter-repo? Could you please summarize on what do I have to do in steps? I really appreciate the help on this
-Shahzad
Beta Was this translation helpful? Give feedback.
All reactions