git tag | sorting_processing_etc | parallel -jobs 2 curl -i -X DELETE \ It uses the Github API, a personal access token, and leverages the utility parallel. Git tag -d $(< git tag | sorting_processing_etc | paste -sd " ")Īs suggested, I've split this answer from my original: Here is a method which is several times faster than xargs and may scale much more with tweaking. git tag | sorting_processing_etc | xargs -L 1 git tag -d This is much faster so we can go back to using xargs and git tag -d, which is sufficient. Method two is broken out as a separate answer elsewhere on this same pageĪfter both of these methods, you'll probably want to delete your local tags too. Using git push with this format tag pushes nothing into each remote ref, erasing it (the normal format for pushing this way is local_ref_path:remote_ref_path). This first method is by far the fastest, maybe 20 to 100 times faster than using xargs, and works with a least several thousand tags at a time. grep -P "my_regex" | sort | head -n -200 etc) : In the examples below you can omit or replace sorting_proccessing_etc with any greping, sorting, tailing or heading you want ( e.g. For both, start with git tag or git ls-remote -tags to make a list of tags you want to delete on the remote. Struggling, I found two much faster ways. Up to 100x faster method for thousands of remote tagsĪfter reading through these answers while needing to delete over 11,000 tags, I learned these methods relying or xargs take far too long, unless you have hours to burn. Worse yet, if there were matching refs that can be fast-forwarded, they would have been published prematurely, even if the user feels that they are not ready yet to be pushed out, which would be a real disaster. When we added a syntax sugar " git push remote -delete" ( man) to " git push" ( man) as a synonym to the canonical git push remote ( man) : syntax at f517f1f (" builtin-push: add ( man) -delete as syntactic sugar for :foo",, Git v1.7.0-rc0 - merge), we weren't careful enough to make sure that is not empty.īlindly rewriting " -delete " to " :" means that an empty string results in refspec " :", which is the syntax to ask for "matching" push that does not delete anything. (Merged by Junio C Hamano - gitster - in commit 1400458, ) push: do not turn -delete '' into a matching push See commit 20e4164 () by Junio C Hamano ( gitster). " git push $there -delete" ( man) should have been diagnosed as an error, but instead turned into a matching push, which has been corrected with Git 2.31 (Q1 2021). Git push -delete origin $TAGNAME is the correct approach (in addition of a local delete).īut: make sure to use Git 2.31+ (Q1 2021). Which can also be shortened to: git push origin release-1.0:release-1.0īy omitting the source ref (the part before the colon), you push 'nothing' to the destination, deleting the ref on the remote end. Tags work the same way: git push origin refs/tags/release-1.0:refs/tags/release-1.0 Which because of default paths, can be shortened to: git push origin master:master Pushing a branch, tag, or other ref to a remote repository involves specifying "which repo, what source, what destination?" git push remote-repo source-ref:destination-refĪ real world example where you push your master branch to the origin's master branch is: git push origin refs/heads/master:refs/heads/master If you also need to delete the local tag, use: git tag -delete tagname If you want to make sure that you cannot accidentally remove the branch instead of the tag, you can specify full ref which will never delete a branch: git push origin :refs/tags/tagname Note that git has tag namespace and branch namespace so you may use the same name for a branch and for a tag. Or, more expressively, use the -delete option (or -d if your git version is older than 1.8.0): git push -delete origin tagname You can push an 'empty' reference to the remote tag name: git push origin :tagname
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |