For releases I usually tag with something like v1.1.0. During my build script I am creating a fwVersion.c file that contains the current git info. Currently, I have commit, and branch info in the file, but I would like to add the tag.
Is this possible?
Listing the available tags in Git is straightforward. Just type git tag (with optional -l or --list ). You can also search for tags that match a particular pattern. The command finds the most recent tag that is reachable from a commit.
Tags are ref's that point to specific points in Git history. Tagging is generally used to capture a point in history that is used for a marked version release (i.e. v1. 0.1). A tag is like a branch that doesn't change. Unlike branches, tags, after being created, have no further history of commits.
View tags for a repository (console)In Repositories, choose the name of the repository where you want to view tags. In the navigation pane, choose Settings. Choose Repository tags.
They're just refs in the refs/tags namespace, but they point to commits instead of tag objects. This means there are no details to show.
Check the documentation for git describe
. It finds the nearest tag to a given commit (that is a tag which points to an ancestor of the commit) and describes that commit in terms of the tag.
If you only want to know if the commit is pointed to by a tag then you can check the output of:
git describe --exact-match <commit-id>
If what you want is the first tag containing the commit then:
git describe --contains <commit>
gives the best answer IMO. If you have frequent tags than using "git tag --contains" on an old commit in a big repository can take a while to run and gives you all of the tags that contain that commit.
This form of git describe runs very quickly and gives you a single output value which is the first tag containing the commit and how far back your commit is.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With