Will git cherry-pick on a tag affect the original tag?

during release runtime I checked the previously released tag and cherry-picked items using git cherry-pick <commit-id>

in it. And created a new tag from it using git tag <tag-name>

.

So my question here is, will it affect the old tag where I cherry-pick the changes? Thanks for any answer in advance.

+3


source to share


2 answers


In one word: no. Tags created after are not intended to be navigated like branch links. You need to deliberately use

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

      

to move the tag v1.0

to another commit. Cherry-selecting other commits (in other words, applying the changes made by those other commits) on top of the checked commit won't affect the tag.

As an example, if v1.0

is a tag and your story looks like this:

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 get

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

      

The tag v1.0

will stay in place, still pointing to commit B.

+3


source


When you select a commit, Git essentially creates a patch from that commit (figuring out what changes were made to it) and applies that to the current HEAD. This process creates a completely new commit with no reference to the original post that you cherry-picked. Git will simply copy the commit message and commit the author and reuse it on a new commit; but other than that, it is a completely separate commit.



So it is no different from creating a new commit yourself. So no, cherry picking, as if it weren't binding, won't affect other commits or tags.

+1


source







All Articles