2

I’ve been trying to find a way to either:

  1. Clone master, delete master

Or

  1. Rename master

The closest I’ve found is: libgit2sharp remove remote branch

I haven’t been able to find a way to accomplish the end result of a newly named master by either method.

I found this link helpful, but haven’t been able to translate it to LibGit2Sharp: Rename master branch for both local and remote Git repositories

Also, regarding that last link, this seems to try to address changing the upstream: Setting upstream on a repo

Any help on this would be greatly appreciated!

-Verxion

Verxion
  • 59
  • 6
  • What have you tried? Did you get an error? If so, what was that error? – Edward Thomson Jun 26 '18 at 12:07
  • I’ve been able to successfully delete my local branch using repo.Branches.Remove. I’ve been able to push that to the remote using repo.Network.Push, but only for OTHER branches. Master is special and doing the same exact thing that works to delete other branches doesn’t work with it. Related, I think is the simple fact that GitHub has this sense of a “base” branch for each repository. It has a web interface to change this (after which you are allowed to delete the previously default branch, including master), but I haven’t found a way to do this with LigGit2Sharp... – Verxion Jun 26 '18 at 14:17
  • If you're asking how to delete the master branch on GitHub: you can't. This has nothing to do with LibGit2Sharp, this is a GitHub construct. Your default branch (by default, "master") is special and cannot be deleted. Most other hosting providers have a similar notion. – Edward Thomson Jun 26 '18 at 14:46
  • GitHub actually allows it to be deleted from the web interface. You just set a different branch as default and then you can delete master. I can do this just fine from the web interface, but I need to do this for HUNDREDS of repositories, so I’d like to code it... – Verxion Jun 26 '18 at 15:44
  • 2
    Right, and GitHub's default branch remains a GitHub concept and not a _git_ concept, so it's not something that you can change with LibGit2Sharp. Check out the GitHub API, which may be able to help you. – Edward Thomson Jun 27 '18 at 09:57

0 Answers0