On a related note, git supports incorporating custom commands via executables available in the `PATH` having the naming convention of: git- Where "command name" in this case would be `archive-branch` and could be defined thusly: #!/bin/sh # git-archive-branch git_branch="${1:-$(git branch --show-current)}" git co main && git tag archive/$git_branch $git_branch && git branch -D $git_branch It then could be invoked the…
Oh oh. Your co alias leaked :)
Archiving Git branches as tags
41–49 of 49 posts
Re: Archiving Git branches as tags
#42Earlier quoted context omitted.
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.
Re: Archiving Git branches as tags
#43I 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
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.
Re: Archiving Git branches as tags
#44Re: Archiving Git branches as tags
#45Earlier quoted context omitted.
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.
Re: Archiving Git branches as tags
#46Earlier quoted context omitted.
True. At work our flow is to tag commits that we want to mark as release candidates and delete feature branches after their PRs are merged/declined. We've never had a need to archive branches.
It seems very useful for archiving branches that never got merged. Sometimes I work on a feature, and it doesn’t quite work out for some reason or another. The branch will probably never get merged, but it’s still useful for reference later when I want to see what didn’t work when taking a second attempt. Currently, those abandoned branches have been polluting my branch list. In the past I have cloned the repo a seco…
It just moves trash from branch list to tag list.
Re: Archiving Git branches as tags
#47I 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
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 y…
I like the idea that branch names starting with . (period) are considered hidden, similarly to files in Unix.
Re: Archiving Git branches as tags
#48Earlier quoted context omitted.
True. At work our flow is to tag commits that we want to mark as release candidates and delete feature branches after their PRs are merged/declined. We've never had a need to archive branches.
if you're deleting branches then why would you need to archive them? What would you even archive if you're deleting them? My deeper question is why are you deleting them in the first place though?
Re: Archiving Git branches as tags
#49Earlier quoted context omitted.
> A tag is a pointer that always refers to the same commit It's not guaranteed not to change. The UI just makes it harder to update.
And anyone whose coworkers replace tags on a regular basis will be familiar with the following message from git when pulling changes: would clobber existing tag Really wish my coworkers would leave old tags as they were heh.