Is there a way to get an edit link leading to the default branch, without having to name it specifically? #194221
-
🏷️ Discussion TypeQuestion BodyIn GitHub can you use I was now wondering, if there is a way to use such a thing in a If this isn't a thing should this be considered a feature request instead. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
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. |
Beta Was this translation helpful? Give feedback.
-
|
🕒 Discussion Activity Reminder 🕒 This Discussion has been labeled as dormant by an automated system for having no activity in the last 60 days. Please consider one the following actions: 1️⃣ Close as Out of Date: If the topic is no longer relevant, close the Discussion as 2️⃣ Provide More Information: Share additional details or context — or let the community know if you've found a solution on your own. 3️⃣ Mark a Reply as Answer: If your question has been answered by a reply, mark the most helpful reply as the solution. Note: This dormant notification will only apply to Discussions with the Thank you for helping bring this Discussion to a resolution! 💬 |
Beta Was this translation helpful? Give feedback.
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.