Git batch Delete remote tags
In my latest team, we used Git as a tool for development and management of our team. We use Git for version control, R & D management, and online deployment. The Git version library is directly used as the Code directory to store online code and release methods. The Code directory of the online environment is simply checkout to the specified tag, quick.
After executing this method for a while, I found a new annoyance, that is, the number of tags in the central version library will become very large. When there are more than 300 tags, this is actually nothing, but we use gitlab to build our own central version library. This gitlab is still a lot of bugs. When there are more tags, the entire website is not very normal, so we need to maintain a small list of tags to maintain a relatively high performance. Then I had a motivation to delete the tag list at the remote end.
I used Google to search for how to delete git tags batch. I found that foreigners say that bulk delete, haha, English is not good.
It is nothing more than some practices in shell, I feel that the actual use is enough.
First, find the tags list to be deleted from the remote end. The key is to use the command.
Git show-ref -- tag
This command can list all the remote tag lists, and then the general processing method under shell.
Git push origin: <tag>
The preceding command will delete the remote tag. Connect with a pipe. Everything is fine.
Git show-ref -- tag | awk '/(. *) (\ s +) (. *) $/{print ":" $2}' | xargs git push origin
The preceding command is a complete command. However, this command will delete all tags at the far end. Use it with caution. If you want to delete tags that meet the conditions, modify the regular expression of the awk command.
After deleting the remote tag and local tag, the deletion method is not the same, but the principle is the same.
Git tag | grep "v1.1.0. \ d $" | xargs git tag-d
For example, the preceding command deletes all local v1.1.0.x tags. This command deletes a maximum of 10 tags.
GitHub Tutorials:
GitHub tutorials
Git tag management details
Git branch management
Git remote repository details
Git local Repository (Repository) Details
Git server setup and Client installation
Git Overview
Share practical GitHub tutorials
How to Build and use Git servers in Ubuntu
Git details: click here
Git: click here
This article permanently updates the link address: