Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Make old git branches invisible without making them unreachable?

Tags:

git

branch

gitk

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 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.

like image 215
Andrew Wagner Avatar asked Mar 03 '11 05:03

Andrew Wagner


2 Answers

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.

like image 177
Josh Lee Avatar answered Nov 02 '22 10:11

Josh Lee


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

like image 26
Graham Borland Avatar answered Nov 02 '22 12:11

Graham Borland