Remove/hide git branches without deleting commit histories

Here’s one alternative: use non-branch references to save the branch-tips before deleting the branch names.

Since these are non-branch references, they won’t show up in git branch output, nor in stuff shown by git log --branches and gitk --branches, for instance. However, they will show up in --all listings, and will retain repository objects.

To create or update a non-branch reference, use git update-ref. Choose a name-space within refs/ that you think will not collide with some future use (current uses are refs/heads/ for branches, refs/tags/ for tags, refs/remotes/ for remote branches, refs/notes/ for notes, and refs/stash for the stash). [Edit, July 2022: refs/namespaces/ is now reserved as well, and refs/replace/ is used by git replace. refs/bisect/, refs/rewritten/, and refs/worktree/ are reserved; refs/original/ is reserved if you will use git filter-branch. Gerrit, if you use it, has more reserved names. The list never seems to stop growing, so use care here.]

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)