GitOps - Viewing and Creating git tags
In a team following continuous delivery based on git tags or otherwise popularly known as GitOps, there will be a frequent need to list the existing tags in a repository in chronological order so that a new tag can be created based on recent commit (HEAD) from master / main branch.
The following chained command will list all the remote tags in chronological order along with latest commit, so that new release tags can be quickly created through command line.
List all annotated tags name with the commit SHA in chronological order along with recent commit id
git fetch origin && git checkout master && git pull && git ls-remote --tags --sort=creatordate origin && git log -n 1
Create a new tag based on master / main branch or specific commit SHA and push the tag to remote server
tag_name="production-v1.0" && git tag -a $tag_name master -m "Production version 1.0" && git push origin $tag_name
Comments
Post a Comment