I use the following script to autotag the current workspace while building even if there are changed (not committed) files:#!/bin/bashtagname=autobuild-test1commitname=autocommit for tag $tagnameset -ehead=`git rev-parse HEAD`test -n $headgit commit -m $commitname -ataghead=`git rev-parse HEAD`git tag $tagname $taghead#or just `git tag $tagname HEAD` for the 2 lines abovegit reset $headThe idea: I commit everything which is not committed to a 'temporary commit' and tag its hash. After doing this, I revert to the original state by resetting to the previous HEAD.In other words: I try to do git commit -a without touching HEAD, staging, stashing and workspace.Pros:this also works if the workspace is dirtythe script is very flexiblethe script doesn't touch any files, doesn't do any checkout or remove operationsCons:the staging state is completely cleared after running the scriptprobably more state modifications which I didn't find yetit is a script. I would prefer a single command for this use caseno proper error handling. if the script fails, HEAD might be changedThis script was inspired by cvs2git which uses the same strategy in cases where it's not clear to which revision a tag belongs to.Is there anything you would change to make this script more rubust and/or to remove some of the cons?
Bash script for tagging the current git workspace including uncommitted changes
git;bash