Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a stable url to always get the default branch in github?

In past you could in most cases just add blob/master/ to a github url get the raw file, i.e. https://github.com/jacoco/jbang-catalog/blob/master/jbang-catalog.json`

Now with old repos using master but new using main that trick don't work on new repos.

Is there a way to avoid having to do a call to the rest api to find default branch main ?

like a magic marker like blob/@default/ or similar ?

like image 866
Max Rydahl Andersen Avatar asked Sep 13 '25 11:09

Max Rydahl Andersen


1 Answers

One solution is to use HEAD. That symbolic name will give you tip of the default branch no matter what its name is.

If you prefer it to redirect to the default branch then instead use - for example https://github.com/jacoco/jbang-catalog/blob/-/jbang-catalog.json

like image 130
Max Rydahl Andersen Avatar answered Sep 15 '25 06:09

Max Rydahl Andersen