Last active
January 11, 2022 22:20
-
-
Save jatubio/978f0c26703eab404df1 to your computer and use it in GitHub Desktop.
Alias to amend and move git tags
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Tags | |
# Return date of tag. (To use in another alias) | |
tag-date = "!git show $1 | awk '{ if ($1 == \"Date:\") { print substr($0, index($0,$3)) }}' | tail -2 | head -1 #" | |
# Show tag message | |
tag-message = "!git show $1 | awk -v capture=0 '{ if(capture) message=message\"\\n\"$0}; BEGIN {message=\"\"}; { if ($1 == \"Date:\" && length(message)==0 ) {capture=1}; if ($1 == \"commit\" ) {capture=0} }; END { print message }' | sed '$ d' | cat -s #" | |
# Get hash of tag commit | |
tag-commit = "!git show $1 | awk '{ if ($1 == \"commit\") { print $2 }}' #" | |
### Amend tag message. Can edit current tag-message. | |
taga = "!GIT_TAG_COMMIT=$(git tag-commit $1) && GIT_COMMITTER_DATE=$(git tag-date $1) && git tag -a $1 $GIT_TAG_COMMIT -f #" | |
### Move tag. Use: git tagm <tagname> <newcommit> | |
tagm = "!GIT_TAG_MESSAGE=$(git tag-message $1) && GIT_COMMITTER_DATE=$(git tag-date $1) && git tag-message $1 && git tag -d $1 && git tag -a $1 $2 -m \"$GIT_TAG_MESSAGE\" #" | |
### Move pushed tag. Use: git tagmp <tagname> <newcommit> | |
tagmp = "!git tagm $1 $2 && git push --delete origin $1 && git push origin $1 #" | |
### Amend pushed tag message | |
tagap = "!git taga $1 && git push origin $1 --force #" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Samples:
Amend tag 'v1.3.1' message:
git taga v1.3.1
If pushed:
git tagap v1.3.1
Move tag v1.3.1 to commit ac5bc6d8:
git tagm v1.3.1 ac5bc6d8
If pushed:
git tagmp v1.3.1 ac5bc6d8