Hacker News new | ask | show | jobs
by kazinator 174 days ago
I don't see the point of this. A git branch is already a kind of tag.

How about just

  # rename branch to archive/ prefix to indicate it is archived
  git branch -m foo-branch archive/foo-branch
3 comments

Branches are expected to change, tags are not. Tags are also mildly harder to change. A tag seems more apt for an archived branch. So I sort of see where OP comes from.
Yeah. But WHY taging instead of renaming the branch ? I don't say if it is a good or bad idea. But I would like to know why.
You can accidentally push to a branch. You can't accidentally push to a tag.
If you read the article, it credits a reddit thread as the source of inspiration; the thread ultimately points to a StackOverflow answer [0] which may offer a better argument as to why they liked yo use this pattern.

[0]: https://stackoverflow.com/a/1309934

Because in git tooling (be it github.com or a tui/gui client like lazygit), git branches are shown more prominently because the expectation is that a branch is something you actively work on (if you're finished with a branch, you delete it).

If you don't anticipate working on a branch but you want to preserve the code you leave it but it starts to clutter that prominent "active" space in most git tools.

This allows you to preserve the code (if you ever want to look at it again) while also de-cluttering the prominent "branches" view.

How would this argument change if git branch recognized the "archive/" convention, or had some other mechanism, such that archived branches are concealed from view unless -a/--all is given?

I like the idea that branch names starting with . (period) are considered hidden, similarly to files in Unix.

FWIW, this is what I do, although typically with the prefix `dead/`, unto which I abandon ideas and misdirected refactoring with reckless abandon.