Search code examples
gittags

Any way to export, remove and later restore git tags?


My project has now more than 50 tags,most of them are in remote and local , and I would like to save the unused ones, remove them, but keeping the possibility to restore one or more of them later.

I don't see any mean to do it, does anyone has a clue ?


Solution

  • You could generate a list of commands to re-add current tags using

    git tag --format="git tag %(refname:strip=2) %(objectname)"
    

    Also you could run git pack-refs --all and then backup .git/packed-refs
    (It's a text-file that will contain all refs, e.g. tags; after running git pack-refs --all. Otherwise some tags may only be found in .git/refs/tags/)