4

I've been unsuccessfully trying to delete a remote tag in git using libgit2sharp (v0.24.0). I followed https://github.com/libgit2/libgit2sharp/issues/466, but neither of the two recommendations are working for me.

I also came across a related post on deleting a remote branch, however, this did not work either.

I have a simple wrapper around the libgit2sharp library and I'm using NUnit to execute the DeleteTagRemote method.

Here is the wrapper code:

public void DeleteTagRemote(string tagName)
{
    using (var repo = new Repository(repoPath))
    {
        var tag = repo.Tags[tagName];
        var remote = repo.Network.Remotes["origin"];

        repo.Network.Push(remote, pushRefSpec: ":" + tag.FriendlyName);
    }
}

This results in LibGit2Sharp.LibGit2SharpException: 'not a valid reference 'TestTag_v0.1'' on the push method.

If I try the other option with objectish: null, destinationSpec: "my-branch", I get

System.ArgumentNullException: 'Value cannot be null.
Parameter name: objectish'

Finally, if I try repo.Network.Push(remote, ":" + tag.CanonicalName);, I get

LibGit2Sharp.LibGit2SharpException: 'failed to rename lockfile to '*.idx': The process cannot access the file because it is being used by another process.

I have gotten committing, creating a tag, pushing both the commit and tag to the remote, and deleting a local tag to work. Not sure what I'm missing with this one.

Avery
  • 2,270
  • 4
  • 33
  • 35
C. Dietz
  • 41
  • 3

0 Answers0