Is there a way for an Open in Codespaces badge to automatically open the current repo instead of the upstream if the current repo is a fork? #202889
Replies: 2 comments 1 reply
|
Not with a static Markdown badge today. The target URL has to identify a repository explicitly: GitHub's documented variants (branch, PR, A fork inherits the README contents literally. GitHub Markdown does not expose an There are two practical choices:
[](https://codespaces.new)That opens “Create a new codespace” with a repository picker. It does not automatically select the current fork, but it avoids silently opening the upstream repository and lets the user select their fork. A redirect service could theoretically examine a query parameter, but the README still has no dynamic current-repository value to pass to it (and relying on the HTTP So if the requirement is both zero configuration in a fork and one click directly to that fork, the built-in badge/deep-link mechanism does not currently support it. The repository selector is the safest generic fallback. |
|
As far as I know, no. The Open in GitHub Codespaces badge/link is tied to the repository that the README is being rendered from, but GitHub doesn't currently provide a parameter or mechanism that says "if this repository is a fork, open the fork instead of the upstream." If someone is viewing the fork's README, the button will open a Codespace for the fork. However, if they're viewing the upstream repository, GitHub has no way to infer which fork they intend to use, so it will open the upstream repository. If your goal is for contributors to work in their own forks, the usual approach is to document that workflow (fork first, then open a Codespace from the fork) rather than relying on the badge to redirect automatically. If anyone knows of a hidden URL parameter or a recent feature that changes this behavior, I'd be interested as well, but I don't believe GitHub currently supports it. |
Uh oh!
There was an error while loading. Please reload this page.
🏷️ Discussion Type
Question
Body
Is there a way to make an "Open in GitHub Codespaces" badge in a repository readme that automatically opens the current repo instead of the upstream if the button is clicked from a fork?
All reactions