π @community
GitHub Community
Is there a way to get an edit link leading to the default branch, without having to name it specifically? #194221
Answered
by
P-r-e-m-i-u-m
Andre601
asked this question in
Repositories
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Category
Repositories
Labels
