Tobias Kienzler Tobias Kienzler -3 years ago 107
Git Question

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

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.

Asking How to prepend the past to a git repository? I followed these instructions. <edit>Then I rebased to include a file that was only in the snapshots, see here.</edit> Since history was rewritten (by
git filter-branch
git rebase
or both?) all tags are still on the original time line* and I'd somehow like to move them to the new one. I think I made all commit-messages with tags unique so I could try writing a script that uses them, but a more general
git move-tags <from> <to>
would be better.

So, is there a way to address "the commit which is N commits after on the new timeline such that the Nth commit after on the old timeline is tagged "? Any other solution except the obvious manual retagging would also be great.

(please feel free to correct that horribly long sentence into plain English...)

*) hey, git solved the grandfather-paradox!

Answer Source

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


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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download