I have some history rewriting to do for which I'd like to keep my original tree intact for now. The rewritten tree should however copy the tags previously used as well. Is there any less manual option than e.g. prepending tag names with the branch name?
git: Is there something like per-branch tags?
5.4k Views Asked by Tobias Kienzler At
2
No, there is nothing like a per-branch tag in git. All branches and tags are just kinds of refs in Git; a ref is just a name that points to a particular revision in the revision history. For instance, if you have
devel
andmaster
branches, andv1.0
andv2.0
tags, the references would look something like this:As you can see, there's nothing tying those tags to any branches; in fact, all of those tags are contained in both the
master
anddevel
branches. By looking inside your.git
repo, you can see that there is really no more structure to a tag than that; it is just a file containing a SHA-1 referencing a commit within.git/refs
, or a line in.git/packed-refs
(tags will frequently be inpacked-refs
because they don't change often, while branches will usually be separate files withingit/refs
).So if you want to rewrite history, and preserve the old tags, you will have to rewrite your tag names. As sehe points out, this is done using
git filter-branch --tag-name-filter
.