Skip to content

Instantly share code, notes, and snippets.

@yuta0801
Created December 26, 2019 17:11
Show Gist options
  • Save yuta0801/e3e99279ffa1aadb47893133abeab835 to your computer and use it in GitHub Desktop.
Save yuta0801/e3e99279ffa1aadb47893133abeab835 to your computer and use it in GitHub Desktop.
Tagging commit like stash/a2c2b7d/0
HASH=$(git rev-parse --short HEAD)
PREFIX="stash/$HASH"
function exist() {
git rev-parse $1 >/dev/null 2>&1
}
for i in {0..9}; do
if exist "$PREFIX/$i"; then
continue
else
TAG="$PREFIX/$i"
break
fi
done
if [ -z "$TAG" ]; then
echo "failed to generate tag"
exit 1
fi
git tag $TAG
echo "Tagged $TAG"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment