libgit2 / libgit2/libgit2sharp

Remove tag

Open
#1,868 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
3.5k
Forks
925
PR merge metrics
No merged PRs in 30d

Description

How do I remove a tag and push the removed tag to a remote repo?

I've tried the following but have been unsuccessful, I can query the tags in the repos but I haven't found a way to remove tags and push to the remote.

`
using System;
using System.Collections.Generic;
using System.IO;
using LibGit2Sharp;

namespace GitTagging
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Remove Tags");

        using (var repo = new Repository("C:\\src\\repo\\.git"))
        {
            var allTags = repo.Tags.ToList();
            var tagnames = new List<string>();
            foreach (var item in allTags)
            {
                tagnames.Add(item.FriendlyName);
            }

            StreamWriter file = new System.IO.StreamWriter("C:\\src\\tags.txt");
            foreach (string line in tagnames)
                file.WriteLine(line);
            file.Close();


            var tagstodelete = File.ReadAllLines("C:\\src\\tags.txt");
            var logList = new List<string>(tagstodelete);
            foreach (var item in logList)
            {
                repo.Tags.Remove(item);
                Remote remote = repo.Remotes["origin"];
                PushResult pushResult = repo.Network.Push(remote, ":refs/tags/" + item, credentialsLibGit2Sharp);
            }

        Console.ReadLine();
    }
}

}

`

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Program.Main example, especially the repo.Tags.Remove and repo.Network.Push calls. Read the LibGit2Sharp tag and push API documentation and verify the expected local and remote tag-removal workflow. Done means providing confirmed usage guidance for both operations.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, git
Domain
devtools
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.