Created
March 19, 2012 17:01
-
-
Save mgilliam/2119327 to your computer and use it in GitHub Desktop.
Remove local and remote tag annotation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Remove annotation from local and remote tags. | |
# | |
# This works fine for simple repositories. However, if a tag checkout would | |
# result in a message about an untracked directory that cannot be removed, | |
# things could get ugly. Before trying this, make a backup that's not | |
# associated with the origin (i.e., `git clone repo repo-bak`) from which to | |
# recover. | |
usage=$( | |
cat <<EOF | |
$0 <repo> | |
EOF | |
) | |
# Defaults | |
repo_default="" | |
: ${target=$repo_default} | |
for last; do true; done | |
target=$last | |
if [ -z $target ] ; then | |
echo "$usage" | |
exit 1 | |
fi | |
cd "$target" | |
for tag in `git tag`; | |
do | |
git checkout $tag | |
if [ -f .gitmodules ] ; then | |
git submodule update | |
fi | |
git tag -f x | |
git tag -d $tag | |
git push origin :refs/tags/$tag | |
git tag $tag | |
done | |
git tag -d x | |
git push --tags |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment