question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with migrating master -> main

See original GitHub issue

We have recently moved the master branch to main on all the Bokeh repos except our bokeh-notebooks repo. This is because our docs headers link to tutorials at a URL that explicitly includes “master”:

https://mybinder.org/v2/gh/bokeh/bokeh-notebooks/master?filepath=tutorial%2F00 - Introduction and Setup.ipynb

If the master branch is deleted, this binder fails to launch. I had heard GH is now redirecting deleted branches to the new default branch, but even if this is true apparently it is not enough to get binder to launch from that URL if only main exists.

Lots of projects are currently considering or implementing such changes. Is there any possible solution to help support this kind of change transparently the binder side? We could obviously try to update things on our end but the that would mean changing tens of thousand of files on s3 to change, which would incur both operational and financial risk.

cc @betatim

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (9 by maintainers)

github_iconTop GitHub Comments

4reactions
minrkcommented, Aug 28, 2020

Given that the scope of the workaround is fairly small and well defined (only for rename away from master for default branch on GitHub—other repo providers perhaps in the future if they provide similar resolution for the default branch), I think we can implement this now/soon with little cost, and it may become obsolete if github implements its own redirect.

2reactions
minrkcommented, Aug 28, 2020

Update: I created https://github.com/minrk/test-default-branch with:

  • default branch: master
  • changed default branch to: main
  • deleted master branch

As far as I can tell, the links for deleted branches redirecting to default is only applied to blob pages, not even tree. I tested with the following links:

tested 2020-08-28, may change as GitHub rolls things out

So if github doesn’t provide a redirect in the api, we could implement this redirect ourselves for renamed master only with:

def get_resolved_ref(ref):
    try:
        return resolve(ref)
    except 404 and ref == 'master':
        repo = GET /repos/:owner/:repo
        if repo.default_branch != 'master':
             # ref is master, which doesn't exist and default branch is not master,
             # support folks renaming default branch away from master
             return resolve(repo.default_branch)
        else:
            raise

I also think we should probably change our code in various places away from hardcoded master to a special value, e.g. $default (must not be a valid ref) that resolves to the repo default branch instead of assuming that to be master (or main, etc.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to migrate master branch to main in Github?
How to migrate master branch to main in Github? · 1: Connect local repo with your remote repo. git remote add origin <remote_github_url>...
Read more >
Migrating your default git branch to main - B12 website
On Juneteenth, B12's engineering team migrated its default git branch names to main, removing the problematic term master. Here's the planning document we ......
Read more >
Git: Moving from Master to Main - Jumping Rivers
The purpose of this post is summarise some of the challenges we faced when moving from master to main , with the goal...
Read more >
How to migrate a git project from using master as the default ...
I want to migrate from using master as the default branch to main . How do I do that without messing up? I've...
Read more >
Issue with git clone after migration into the new server
One possibility is that the project uses the main branch as default head branch, while your local git client config expects that master...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found