Today, we renamed the default branch of
main (see the bottom for the backstory). This caused existing “view” links to
master-post-microsoft to break, but not in the way I expected. For example, this link (which appeared in one of our documents outside GitHub):
now redirects to:
Both pages would be 404s, but the
main/-post-microsoft in the second URL makes no sense. It looks like GitHub intended to redirect the
master branch to
main, but it also matches
master at the beginning of a longer branch name and replaces it with
main/, leaving the rest of the branch name as a path component. I feel pretty confident in saying this is a bug.
For comparison, a link to a deleted branch that doesn’t begin with
master shows a 404 without being redirected:
The renaming page states:
We’ve updated GitHub.com to redirect links that contain the deleted branch name such as
masterto the corresponding link in the repository’s new default branch.
According to that documentation, the expected behavior would be to redirect both links to the same paths in our new default branch (
It’s possible that GitHub intentionally changed the design to apply the redirection only to a deleted branch named
master and neglected to update the documentation. If so, then the behavior in the second example is as intended and only the documentation needs to be updated to match it, but the behavior in the first example is still a bug: the URL should be left to show a 404 as is rather than being redirected to a garbled URL.
I’m submitting this report here according to these instructions. I didn’t find any previous discussion of the issue in a few web searches. (I had to prevent several URLs in this post from being formatted as links to work around the forum’s new user restriction, “Sorry, new users can only put 2 links in a post”, and to bypass the automatic edit “Github link was replaced with a permanent link”, both of which you can see are counterproductive in this case.)
For anyone curious: The awkward
master-post-microsoft name arose after I foolishly submitted a PR from our
master to another repository, not realizing that (1) we’d want to make more commits on our
master before this PR was merged without them becoming part of the PR and (2) I could not change the source branch name after creating the PR (a GitHub limitation that could probably be the subject of a separate enhancement request).