开发者

Make old git branches invisible without making them unreachable?

开发者 https://www.devze.com 2023-02-14 17:41 出处:网络
Is there a way to make a git branch cease to show up when you type \"git branch\", but still remain reachable in the history, i.e. via gitk?I have many old branches that I want to get out of my sight,

Is there a way to make a git branch cease to show up when you type "git branch", but still remain reachable in the history, i.e. via gitk? I have many old branches that I want to get out of my sight, but I see no reason to delete history even of development dead-ends in a world with 开发者_StackOverflow社区terabyte hard disks.

Tags might be close to what I'm looking for, but I don't want to have to name my dead ends beyond their commit message. Furthermore, I want reserve tags for especially good points in the mainline development history.


You can make up your own namespace inside refs/, such as refs/historic/foo, by manually using the update-ref command (and then deleting the branch).

Some caveats of this approach:

  • They do not show up in git branch, but they do show up in git log --decorate and in gitk without any extra options, and you may use git show-ref to list all refs.
  • They are not automatically fetched, so you if you want them transported you will have to use ls-remote and fetch them by hand.

However, it seems like a nice way to archive a branch, since it pops up when browsing history, can be explicitly listed, and does not clutter the branch or tag namespace.


Push the old branches to a remote repository on one of the many free Git hosting sites.


git revision IDs are (nearly) unique. If you want the old branches to remain reachable, just don't garbage collect them; you can always bring them back by directly checking out their revision ID. This will require tweaking the .git/config of your repository to avoid having a git gc clear out the revisions no longer reachable directly from the HEAD of any branch.

0

精彩评论

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