Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will cherry-picking on a tag affect the latter?

While doing a release, I checked out the previously released tag and cherry-picked the new items (using git cherry-pick <commit-id>) into it. Then, I created a new tag using git tag <tag-name>.

Will this affect the old tag I cherry-picked the changes into?

like image 482
Stranger Avatar asked Aug 22 '14 13:08

Stranger


1 Answers

In one word: no. Tags, once created, are not meant to move around like branch references do. You'd need to deliberately use

git tag --force v1.0 <some-other-commit>

to move the v1.0 tag to some other commit. Cherry-picking other commits (in other words, applying the changes introduced by those other commits) on top of a tagged commit won't affect the tag.

As an example, if v1.0 is a tag and your history looks as follows,

A -- B [master,v1.0]
 \
  C -- D [develop]

and then you run

git checkout v1.0
git checkout -b rc1.1
git cherry-pick C
git cherry-pick D

you'll end up with

A -- B [master,v1.0]
 \    \
  \    C' -- D' [HEAD,rc1.1]  
   \
    C -- D [develop]

The v1.0 tag will stay in place, still pointing at commit B.

like image 50
jub0bs Avatar answered Sep 23 '22 20:09

jub0bs