Skip to content

Instantly share code, notes, and snippets.

@ZeroDragon
Last active October 11, 2017 21:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ZeroDragon/2ba502436970e2a58607f2e04768c3e3 to your computer and use it in GitHub Desktop.
Save ZeroDragon/2ba502436970e2a58607f2e04768c3e3 to your computer and use it in GitHub Desktop.
Git retagger

Rettager

This file will help you to create tags in your git repository.
Also you can use it to move a tag from commit to commit (for build tags).

Usage

Just add retagger.sh to anyplace you want (bin maybe) and add execution permissions.
Also you can just leave it in your Documents or Downloads and just add an alias in your .bashrc file

Then just retagger inside a git folder
retagger will ask you to create a new tag in current commit (and show you the last one for easy version bump)
Then ask you to move a tag (could be latest or LTS dunno something to keep updated.
Finally will ask you to push the tags to origin.

At any time you can control+c to cancel or leave blank to skip a step

I'll update this gist on improvements

#!/bin/bash
echo "Last tag is:"
git tag | sed -e '$!d'
echo "Want to tag current commit? type the name of the tag (leave empty to skip)"
read current
if [ "$current" != "" ]; then
git tag -a $current
fi
echo "Type the name of the tag you want to move (leave blank to skip)"
read movement
if [ "$current" != "" ]; then
git tag -af $movement
fi
read -p "Want to push all updated tags? (y/N)" -n 1 -r
echo # (optional) move to a new line
if [[ $REPLY =~ ^[Yy]$ ]]; then
git push origin :$movement
git push --tags
fi
echo "Done!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment