Skip to content
nulltoken edited this page May 25, 2011 · 8 revisions

git-tag

Listing all tags

Git

$ git tag

LibGit2Sharp

using (var repo = new Repository("path/to/your/repo"))
{
    foreach (Tag t in repo.Tags)
    {
        Console.WriteLine(t.Name);
    }
}

Displaying the tag message, or the commit message if the tag is not annotated

Git

$ git tag -n -l myTag

LibGit2Sharp

using (var repo = new Repository("path/to/your/repo"))
{
    Tag t = repo.Tags["your-tag-name"];
    Console.WriteLine(t.IsAnnotated ? t.Annotation.Message : ((Commit) t.Target).MessageShort);
}

Creating tags

Lightweight tag pointing at the current HEAD

Git

$ git tag a-nice-tag-name

LibGit2Sharp

using (var repo = new Repository("path/to/your/repo"))
{
    Tag t = repo.ApplyTag("a-nice-tag-name");
}

Lightweight tag pointing at a specific target

Annotated tag pointing at a specific target

Overwriting an existing tag

Deleting a tag

Clone this wiki locally