Open jnehlmeier opened 10 months ago
It would be nice to have a way to optionally prune local tags during fetch
So, you ask for an option to delete all local tags on fetch? Why would it be nice?
A team developing on the main branch and forking release branches usually makes tags on release branches for maintenance releases. E.g. a release/1.0.x branch with tags 1.0.0, 1.0.1, 1.0.2 and so on. At some point release/1.0.x is outdated and can be deleted together with the corresponding tags.
Now chances are very high that one developer in the team pushes all tags again accidentally. Fork already always does git fetch --prune
but because pruning tags is across all branches, even local branches that never existed on the server, pruning tags should be optional.
In my case it could be turned on by default because tags are only used on release branches and no developer uses tags locally for their own work on features/fixes. Of course this behavior can be configured in git config but then it is active all the time. So a checkbox during fetch/pull or a dedicated button to prune tags would be useful.
I think you should create a repository custom command and run it from the Open-in
dropdown. You can even share such a command with other repository users.
Repository -> Settings for this repository -> Custom Commands -> + -> Repository Custom Command
Open-in dropdown:
Yes that is what I currently do. But even the git documentation linked above says
Since keeping up-to-date with both branches and tags on the remote is a
common use-case the --prune-tags option can be supplied along with --prune
to prune local tags that donโt exist on the remote, and force-update those
tags that differ.
That is actually the reason why they implemented that option. Before you had to use --prune refs/tags/*:refs/tags/*
.
So I figured it would be nice to have that available out of the box in Fork.
Btw: I didn't like the fact that repository custom commands need to reference the remote name explicitly. The remote might have a different name, especially when sharing the command. Maybe remote custom commands with a ${remote:name} variable is missing?
I didn't like the fact that repository custom commands need to reference the remote name explicitly. The remote might have a different name, especially when sharing the command.
You can get it from git:
$remote=git remote
git fetch $remote --prune --prune-tags
Hm yes, although it might break for people who have multiple remotes. Sure I could build a loop or something but you might just want to execute it for one remote. Having remote custom commands in the context menu of a remote is still preferable I think.
I usually have multiple remotes if I track a public project (e.g. on GitHub), apply some changes and push it to a different, private git server.
although it might break for people who have multiple remotes.
Yes, same as the proposed ${remote:name}
variable. It was just a suggestion that what you want can already be achieved using custom commands.
I usually have multiple remotes
Bash is quite flexible. Just implement that the way you like.
although it might break for people who have multiple remotes.
Yes, same as the proposed
${remote:name}
variable.
Hmm maybe there was some misunderstanding. If Fork would have custom commands for remotes, then these custom commands would be shown in the context menu of a remote. So if a specific remote is selected and that custom command for that remote is triggered, then ${remote:name}
would contain the name of that remote.
So Fork would then have custom commands for:
Hey. I've hit a case where the original request might be useful. We have a latest
tag which our CI pipeline creates for us and when it does it removes the last tag and move it to the current commit.
In this case I can see I get a warning on fetch and so have to remove the local tag and fetch again. Having the ability to prune tags in this case would be really useful. ๐
The custom action would fix this, and I know I can then update my hotkeys (I think) to then point at the custom action instead of do the custom fetch. But might be nice to have a checkbox in the fetch dialog to allow this (or something like it). ๐
It would be nice to have a way to optionally prune local tags during fetch:
git fetch <remote> --prune --prune-tags
.See https://git-scm.com/docs/git-fetch#_pruning for some details on how git will behave when using
--prune-tags
.