I figured out how to do this in a generic way in git (this may break in the future).
The following variables are used:
BRANCH_NAME # I think this can be anything REPOSITORY_URL COMMIT_HASH # The commit to tag TAG_NAME # The name of the tag
For git push to work, you need to have a .git directory created as follows:
mkdir -p .git/objects .git/refs echo 'ref: refs/heads/$BRANCH_NAME' > .git/HEAD printf '[remote "origin"]\n url = $REPOSITORY_URL'
Additionally, you need to have a "commit" object in the objects directory. This file has a bit of information that's difficult to transfer over and re-create. It's easier to just copy the file over (it's a small file). The following will get the file:
mkdir -p output_directory/objects/${COMMIT_HASH:0:2}/ cp .git/objects/.git/objects/${COMMIT_HASH:0:2}/${COMMIT_HASH:2} output_directory/objects/${COMMIT_HASH:0:2}/${COMMIT_HASH:2}
And then when you're ready, you can copy this file to the new stub git repository in the .git/objects/${COMMIT_HASH:0:2}/${COMMIT_HASH:2} directory.
Then in the new stub git directory, push the new tag like this:
git push +${COMMIT_HASH}:refs/tags/${TAG_NAME}
Remember to set up your git credentials. This can be done as follows:
git config credential.helper store echo "https://$GIT_USERNAME:$GIT_PASSWORD@$GIT_REPOSITORY_DOMAIN" > ~/.git-credentials