Skip to content

Instantly share code, notes, and snippets.

@yitsushi
Created October 22, 2015 14:17
Show Gist options
  • Select an option

  • Save yitsushi/6e625e67d316a8e01c04 to your computer and use it in GitHub Desktop.

Select an option

Save yitsushi/6e625e67d316a8e01c04 to your computer and use it in GitHub Desktop.
Auto tag working directory before staging. Useful to quick revert if the new codebase failed (build server? Test? use them instead :D).
#!/bin/sh
git fetch --tags && \
git tag | \
grep "autotag-`date +"%Y%m%d"`" > /dev/null \
|| git tag "autotag-`date +"%Y%m%d"`" -m 'autotag' \
&& git tag "autotag-`date +"%Y%m%d"`-"$((`git tag | sort -n | tail -n 1 | sed -Ee 's/autotag-[0-9]{8}-?([0-9]*)/\1/g'` + 1))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment