Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I push hotfix to a tag in git

Tags:

git

git-branch

I got a master branch with tags (v1, v2, etc) ..clients still download different versions from build server. And we need to put a hot fix (security issue) on each versions. Now I can pull from each tags apply the hot fix but don't know how to push back to same tag again? I don't want to push old version to the front of the master branch again.. I don't know what's a right way to do this?

like image 514
user3784080 Avatar asked Dec 25 '22 02:12

user3784080


1 Answers

Assuming master contains the hotfix commit and is already ahead of both v1 and v2:

git checkout v1
git cherry-pick <commit-with-hotfix>
git tag v1.1
git checkout v2
git cherry-pick <commit-with-hotfix>
git tag v2.1
git push --tags origin
git checkout master

When checking out tags, you'll be warned about detached HEAD. No worries.

It's very evil and rude to move tags from one version to the other, as in the wild, everybody is referring to your software versions by tag. If you do it, you will never know whether someone has the hotfixed version or not when referring to v1. Hence v1.1 and v2.1.

git help tag has a long section about retagging. General advice: DO NOT.

If you absolutely insist on updating the software under the same tag, well, they can be deleted. Example with v1:

git checkout v1
git cherry-pick <commit-with-hotfix>
git tag -d v1
git tag v1
git push --force --tags origin
like image 84
SzG Avatar answered Jan 06 '23 06:01

SzG