Can tags be automatically moved after a git filter-branch and rebase?

前端 未结 5 614
别那么骄傲
别那么骄傲 2020-11-30 10:18

edit The question boils down to \"Can git rebase be instructed to rebase tags, too?\" But an answer to the original question would also help.

相关标签:
5条回答
  • I have put together my own python implementation, git rebasetags

    In case the rebase is interactive, you will be presented with a bash shell where you can make the changes. Upon exiting that shell, the tags will be restored.

    From this post

    0 讨论(0)
  • 2020-11-30 10:54

    There is no built in way to do what you want using git. 'git rebase --tags' might be interesting but it does not exist.

    If the commit messages are identical as you say then you could go through each tag in refs/tags, do:

    'git log -1 --pretty=oneline <tagname>'
    

    Compare the commit message to the full list:

    'git log --pretty=oneline <newbranches>'
    

    If you find a match (and the SHA1 hash is different) then do:

    'git tag --force <tagname> <new SHA1>'
    
    0 讨论(0)
  • 2020-11-30 10:55

    I’ve written a script that does this.

    $ git-rebase-tags master
    Rebasing 107 tags onto 'master'
    Can't rebase tag 'staging-deploy-01' because there are no identical commits on 'master'
    Pointed tag 'v0.0.11' at commit 81e16f2ca1bc7802547bf19c1dba1a68212eafff
    Pointed tag 'v0.0.12' at commit 17051cc28084dd56ae56e96767bceee46217c02d
    Pointed tag 'v0.0.13' at commit 5d795076ba4b33f81d327dcf9bff727cef7771a2
    [...]
    

    See gist.github.com/908381.

    But even better, use the --tag-name-filter option built into git-filter-branch(1).

    0 讨论(0)
  • 2020-11-30 10:58

    There is a way to make git filter-branch automatically update modified tags using the --tag-name-filter option, as described in this answer.

    0 讨论(0)
  • 2020-11-30 11:01

    According to Thomas Rast at http://git.661346.n2.nabble.com/Rebase-with-tags-td5582971.html:

    Leonid Podolny wrote:

    Is it possible, at least, to receive a set of (old commit, new commit) pairs, so that I will write a little script that will do that for me?

    The post-rewrite hook gets this list, so you can use that if you want to.

    0 讨论(0)
提交回复
热议问题