TL;DR
A git alias can convert a branch into a tag and delete the branch to keep branch lists tidy, while still allowing tab completion for branch names. The trick wraps the alias in a bash function and uses the official git completion scripts; zsh users on macOS may need to link Xcode's completion files and adjust their .zshrc.
What happened
The author published a git alias that “archives” a branch by tagging it under an archive/ prefix and then deleting the branch. The alias is defined in the user's git configuration and is implemented as an immediately executed bash function. That wrapping is used to borrow completion behavior: the function begins with a no-op reference to git switch so git uses the same completion rules for the alias as for git switch. The alias accepts an optional branch argument and defaults to the current branch when none is provided. Because the completion behavior depends on the official git completion scripts, the post notes zsh’s bundled completion does not accept the same completion-style hint; for macOS users with Xcode’s git, the solution is to symlink the supplied git-completion.zsh into the system zsh functions directory and point zsh’s completion style to the git-completion.bash file in .zshrc. The writeup credits a reddit thread for the original idea.
Why it matters
- Converts inactive branches into tags to reduce branch clutter across tooling.
- Preserves branch history as a tag so references to commits are retained.
- Allows using tab-completion with the alias, maintaining a familiar workflow.
- Requires the official git completion scripts; zsh’s default completion may not work without adjustments.
Key facts
- The alias is defined under the [alias] section of ~/.gitconfig and is implemented as an immediately invoked bash function.
- When run, it tags the target branch under an archive/ namespace and then deletes the branch locally.
- If no branch name is supplied to the alias, it defaults to the currently checked-out branch.
- The function starts with a no-op reference to git switch so git will apply the same completion rules to the alias as to git switch.
- Shell completion support depends on the official git completion scripts rather than zsh’s built-in git completion.
- On macOS with the Xcode Developer Tools version of git, the post suggests symlinking git-completion.zsh into /usr/local/share/zsh/site-functions/_git.
- The post also recommends adding a zstyle entry in ~/.zshrc pointing to git-completion.bash because git-completion.zsh relies on the bash completion script.
- Credit for the idea is attributed to a reddit thread.
What to watch next
- Whether archived tags need to be pushed to a remote for team visibility is not confirmed in the source.
- How this change interacts with open pull requests or remote branches is not confirmed in the source.
- Any effects on CI systems that rely on branch names are not confirmed in the source.
Quick glossary
- git branch: A movable pointer to a commit, used to isolate development lines in a repository.
- git tag: A named reference that typically points to a specific commit, often used for releases or archival markers.
- shell completion: A shell feature that expands commands, options or arguments when you press the tab key.
- git alias: A shortcut defined in git configuration that maps a short name to one or more git commands or a script.
- zsh: A Unix shell and command interpreter that provides advanced features such as programmable completion.
Reader FAQ
What does the alias actually do?
It creates a tag named archive/<branch> pointing at the branch, then deletes the local branch; if no branch is supplied it uses the current branch.
How does tab completion work for the alias?
The alias is wrapped in an immediately executed bash function whose first line references git switch; that prompts git to apply git switch’s completion rules to the alias.
Do I need the official git completion scripts?
Yes — the post notes zsh’s bundled git completion does not support the required completion style and recommends loading the official git completion scripts.
Are steps for macOS with Xcode provided?
Yes — the post outlines linking Xcode’s git-completion.zsh into /usr/local/share/zsh/site-functions and adding a zstyle entry in ~/.zshrc to point to git-completion.bash.
Will this push tags or delete remote branches?
not confirmed in the source

Archiving git branches as tags 22 December 2025 I have a spicy git alias that allows me to "archive" old git branches by converting them to tags, making them less…
Sources
- Archiving Git branches as tags
- How can I archive git branches?
- Git Workflows: Archiving Old Branches – Aaron West's
Related posts
- Reverse Interview: Questions Software Engineers Must Ask Employers
- The Reverse Interview: Key Questions Software Engineers Must Ask in Interviews
- US Trade Dominance Is Poised to Erode as Tariff Battles Intensify