VOOZH about

URL: https://github.com/orgs/community/discussions/194221

⇱ Is there a way to get an edit link leading to the default branch, without having to name it specifically? Β· community Β· Discussion #194221 Β· GitHub


Skip to content

πŸ‘ @community
GitHub Community

Is there a way to get an edit link leading to the default branch, without having to name it specifically? #194221

πŸ‘ Image
Andre601

Answered by P-r-e-m-i-u-m

Yo @Andre601 β€” unfortunately, using HEAD doesn't work for /edit/ URLs because HEAD is a symbolic reference to the current commit, not a branch name. The editor needs a real branch target to apply changes to.
Right now, GitHub doesn't support a "default branch wildcard" for edit links. The URL structure strictly requires a branch name (like main or master).
You're right that fetching the default branch via API is the robust way, but for a quick hack without API calls? You can usually safely assume main in 2026. Most repos have migrated, and the edge cases are small enough that it might be worth the risk for your tool.

Replies: 2 comments

πŸ‘ Image
P-r-e-m-i-u-m

0 replies
Answer selected by Andre601

πŸ‘ Image
github-actions[bot]
Bot

0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.