Raymond Raymond

Git - Push Tags and Commits Atomically

event 2021-04-07 visibility 2,312 comment 0 insights toc
more_vert
insights Stats
toc Table of contents

Context

When adding tags to a certain commit in git local repository, it might be important to push the tags and commits to remote repository simultaneously to ensure CI/CD pipeline is triggered correctly. For example, if build pipeline has steps that are created with custom condition which is based on tag patterns. For this scenario, you may not want to trigger the pipeline until the tag is pushed. 

To push tags and commits simultaneously, you will need to use different commands in different version.

From git 2.4

Since Git 2.4, we can use the following command to push tags and commits at the same time:

git push --atomic origin <branch name> <tag>

For example, the following command push the commits to origin master branch together with tag reference tag-name

git push --atomic origin master tag-name

References

Push git commits & tags simultaneously - Stack Overflow

More from Kontext
comment Comments
No comments yet.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts