Git - Push Tags and Commits Atomically

visibility 326 comment 0 access_time 7m languageEnglish

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

copyright This page is subject to Site terms.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

More from Kontext
visibility 277
thumb_up 1
access_time 7d
visibility 49
thumb_up 0
access_time 9m
visibility 1,083
thumb_up 0
access_time 2y