Sourcegraph Not Displaying the Correct HEAD Branch


This article applies to users facing issues with Sourcegraph not displaying the correct HEAD branch of a given repository.


Sometimes, despite the correct HEAD branch being set in the code host, Sourcegraph does not reflect it accurately. The HEAD branch in the app might not match the HEAD branch in the actual repository, leading to potential confusion and disruptions in workflow.

Troubleshooting Steps

  1. Check that the branch is visible in the app. Open the repository in the app and ensure the branch is listed in the Branches dropdown to confirm Sourcegraph does recognize this branch.

  2. Refetch/reclone the repository to get the latest data. There might be an issue with Sourcegraph needing the latest information about the repository. Refetching or recloning the repository can rectify this issue. 

  3. Look for any issues with fetching or cloning. Check for errors in the UI or gitserver and repo updater logs. If there are issues with cloning, Sourcegraph might need updated repo information.
  4. Clone the repository manually inside gitserver. Using your command line interface, clone the repository directly into your gitserver. You can do this with the command git clone <repo-url>

  5. Run git symbolic-ref HEAD to show the HEAD. After cloning the repository in the previous step, navigate into the repository directory and run git symbolic-ref HEAD. This command will display the current HEAD reference. Confirm if the HEAD is what is expected.

  6. Run 'git remote show ./' In the repository directory, run this command to show information about the remote repository.

  7. Run git remote show <repo-url>. Replace <repo-url> Run this command with your repository's URL to gather more information about the remote repository.

  8. Check access controls on the code host. Make sure the user has the necessary permissions to access the branch. Access controls might be why Sourcegraph cannot display the correct HEAD branch.


After following the above troubleshooting steps, you should be able to identify and resolve the problem. If the issue is with the app not having the latest data, fetching or cloning the repository again should solve the problem. If the issue lies in access controls, adjusting the permissions should allow the app to display the correct HEAD branch.

Additional Information

It could be a bug if the problem persists even after following the troubleshooting steps and solutions/workarounds. Remember to provide all necessary information, including the steps you've taken.

Was this article helpful?
0 out of 0 found this helpful

Articles in this section