Add new commit to the existing Git tag

后端 未结 2 1626
没有蜡笔的小新
没有蜡笔的小新 2021-01-30 21:41

I have created a Git tag as v1.1 using

git tag -a v1.1 -m \'my version 1.1\'

and I pushed that tag. Later, I made some changes re

2条回答
  •  庸人自扰
    2021-01-30 22:46

    You can't put a new commit into an existing tag without breaking an important Git guideline: Never(*) modify commits that you have published.

    Tags in Git aren't meant to be mutable. Once you push a tag out there, leave it alone.

    You can, however, add some changes on top of v1.1 and release something like v1.1.1 or v1.2. One way of doing that would be

    # Create a new branch from tag v1.1
    git checkout -b newbranch v1.1
    
    # Do some work and commit it
    
    # Create a new tag from your work
    git tag -a -m "Tag version 1.1.1, a bugfix release" v1.1.1
    

    (*) Unless you have a really super special reason for doing so, and only if you completely understand the implications, and even then, don't make a habit of it.

提交回复
热议问题