hub icon indicating copy to clipboard operation
hub copied to clipboard

Allow the default branch to be main (or whatever your choose) rather than master

Open samanthamjohn opened this issue 5 years ago • 4 comments

The problem I'm trying to solve: I renamed my default branch to main instead of master because I wanted to move away from using the language of oppression in my programming tools: https://tools.ietf.org/id/draft-knodel-terminology-00.html#rfc.section.1.1.1

How I imagine hub could expose this functionality: hub --set-default main would allow you to change the default branch to main or whatever you chose.

samanthamjohn avatar Jul 07 '20 19:07 samanthamjohn

As a starting point, it looks like this may be coded in DefaultBranch which is then called by MasterBranch. Are there other areas where it's hardcoded?

https://github.com/github/hub/blob/93537d457500c1d9f2e5671b9b9b1ebf90a55668/github/localrepo.go#L107-L125

archaeocharlie avatar Jul 10 '20 16:07 archaeocharlie

@samjohn Thanks for opening this!

To clarify, is this request that hub adds functionality to rename the default branch in a specific repo?

@archaeocharlie That's a good find, but I think this issue is separate than the functionality proposed in this thread. If some hub doesn't handle well when a default branch is named differently than "master", please open an issue providing more details! 🙇

mislav avatar Aug 02 '20 11:08 mislav

It appears that hub does not respect the renaming of a default branch. We have changed our default branch on GH to 'main' (without deleting master), but hub opens PRs against 'master' by default.

DeuceTheCoder avatar Aug 21 '20 18:08 DeuceTheCoder

@DeuceTheCoder This is because git keeps a reference to the old default branch in your local clone. Update it by doing:

git remote set-head origin main

mislav avatar Aug 22 '20 08:08 mislav