9

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.

Andrew Wagner
  • 22,677
  • 21
  • 86
  • 100

3 Answers3

6

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.

Josh Lee
  • 171,072
  • 38
  • 269
  • 275
4

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

Graham Borland
  • 60,055
  • 21
  • 138
  • 179
  • ...or, more efficiently and conveniently, to a locally cloned repository. On linux, hard links will be used automatically to share storage between the clone and the original. – Andrew Wagner Jun 11 '11 at 04:05
-3

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.

Borealid
  • 95,191
  • 9
  • 106
  • 122
  • 4
    Disabling auto gc is a poor choice: an actively developed repository will consume a lot more space. – Josh Lee Mar 03 '11 at 16:30