How would you clean up unused side-branches in your commit trees (not real git branches)?
Example (tree, fake-commit-hash, commit message, optional [pointers]):
* 0001 last commit [master] [origin/master] [HEAD]
| * 0002 old, unused merge
|/|
* | 0003 some remote commits
* | 0004 another commit from remote
| * 0005 old, unused commits
|/
* 0006 old tree
The path 0001, 0003, 0004, 0006 should stay untouched, but the commits 0002 and 0005 are not useful and aren't doing any good. How do you delete the commits 0002 and 0005?
tarsius wrote in an answer to another question:
which clears the reflog and then cleans up the repository. Cleaning the reflog at first doesn't always work, because meaningles commits marked by the reflog are kept alive by
git-gc
as long as the reflog doesn't expire (which is 90 days by default).After doing this all dangling commits are really gone, as far as I understood. So one should be sure that one really doesn't need all of them anymore. If one really wants to keep some of the dangling commits, one can:
or use git format-patch to store the whole commit in a text file.