How to clean up unused side-branches in your commit trees?

那年仲夏 提交于 2019-12-05 06:51:04
erikbwork

tarsius wrote in an answer to another question:

git reflog expire --expire=now --all
git gc --prune=now

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:

git checkout <dangling_commit_id>
git branch <new_branch_name_of_your_choice>

or use git format-patch to store the whole commit in a text file.

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