Is there a simple command to convert a branch to a tag?

后端 未结 3 1185

I am about to complete a tedious process of converting \"dumb snapshots\" to git. This process has been going very well (thanks to this rename process), but now I realized that

3条回答
  •  感动是毒
    2021-02-02 09:37

    Per Andy's answer, I've made an alias that can also be used for the same thing:

    [alias]
    branch2tag = "!sh -c 'set -e;git tag $1 refs/heads/$1;git branch -D $1' -"
    

    Usage

    If you want to convert branch bug-2483 to a tag (while your main branch is master) write:

    git branch2tag bug-2483 master
    

    UPDATE 1

    Changed to reflect the solution proposed by kauppi.

提交回复
热议问题