Archiving Git Branches as Tags

Turning old branches into tags to tidy repos, sparking cheers, yawns, and speed rants

TLDR: A dev alias turns old code branches into tags to clean up projects. The comments split between praise, calls to use a separate backup remote instead, and complaints that the required completion tool is slow on Macs—making it either a smart tidy-up or a new headache.

A developer drops a spicy trick: one command turns old code branches (think work-in-progress lanes) into tags (sticky labels) and deletes the branch, making clutter vanish from your tools. The twist? A clever function makes tab-completion work like magic—but only with the official Git completion and some macOS setup. Non-tech translation: it’s “tag it and bag it” for your code. Cue the comment section chaos.

Fans like ziml77 call it “sensible,” arguing a tag is just a label that doesn’t move, perfect for retired work. Skeptics like PunchyHamster side-eye the whole idea—“how often do you revisit those anyway?”—with the typo “tagches” instantly becoming a meme. Then tonymet brings the “actually…” energy, pushing a backup remote strategy: keep all your branches alive in a side repo and hide them locally with naming tricks. The real brawl erupts over performance: derriz says the official completion script is “effectively unusable” on big macOS projects, blasting “smart” completions that take seconds as worse than useless.

So yes, the alias is slick, but the crowd is split: tidy minimalists vs backup maximalists, with a bonus macOS speed rant. It’s Git meets Marie Kondo, and the comments are doing the decluttering dance here and here!

Key Points

  • A Git alias archives branches by tagging them as archive/<branch> and then deleting the branch.
  • The alias uses an immediately executed bash function with “: git switch” to inherit git switch-style completion.
  • The function selects the target branch (argument or current), switches to main, creates a tag, and deletes the branch.
  • The completion trick requires the official Git completion; zsh’s default Git completion does not support this style.
  • macOS setup includes linking Xcode’s git-completion.zsh and configuring .zshrc to reference git-completion.bash.

Hottest takes

"Seems like a sensible way to archive branches" — ziml77
"Seems very niche" — PunchyHamster
"it’s effectively unusable" — derriz
Made with <3 by @siedrix and @shesho from CDMX. Powered by Forge&Hive.