diff --git a/readthedocs/projects/views/private.py b/readthedocs/projects/views/private.py index a56a70566ca..a1d64ea6df3 100644 --- a/readthedocs/projects/views/private.py +++ b/readthedocs/projects/views/private.py @@ -357,6 +357,7 @@ def process_step(self, form): # pylint: disable=too-many-nested-blocks if isinstance(form, ProjectBasicsForm): remote_repository = form.cleaned_data.get("remote_repository") + default_branch = form.cleaned_data.get("default_branch") if remote_repository and remote_repository.vcs_provider == GITHUB: remote_repository_relations = ( remote_repository.remote_repository_relations.filter( @@ -377,8 +378,11 @@ def process_step(self, form): "readthedocs.yml", ]: try: + querystrings = ( + f"?ref={default_branch}" if default_branch else "" + ) response = session.head( - f"https://api.github.com/repos/{remote_repository.full_name}/contents/{yaml}", + f"https://api.github.com/repos/{remote_repository.full_name}/contents/{yaml}{querystrings}", timeout=1, ) if response.ok: