Adding repositories to Sourcegraph Cloud

Sourcegraph Cloud lets you add repositories to search with Sourcegraph. You can add repositories you own or collaborate on from GitHub or GitLab, or add other public repositories from GitHub or Gitlab.

Adding repositories you own or collaborate on from GitHub or GitLab

To add repositories you own or collaborate on from GitHub or GitLab, you must first create a code host connection:

  1. Go to User menu > Settings in the top navigation bar.
  2. Go to Code host connections in the sidebar navigation.
  3. Connect with GitHub and/or Gitlab using OAuth, or choose “Connect with access token” to enter a manually-created access token for the given code host.

Once you’ve connected with a code host, you can add repositories:

  1. Go to User menu > Settings in the top navigation bar.
  2. Go to Repositories in the sidebar navigation.
  3. Press the Manage Repositories button.
  4. Choose the public repositories you own or collaborate on from your connected code hosts that you want to search with Sourcegraph.
  5. Press the Save button.

Adding other public repositories from GitHub or GitLab

To add public repositories from GitHub or Gitlab without creating a code host connection:

  1. Go to User menu > Settings in the top navigation bar.
  2. Go to Repositories in the sidebar navigation.
  3. Press the Manage Repositories button.
  4. Check Sync specific public repositories by URL under Other public repositories
  5. Specify public repositories on GitHub and GitLab using complete URLs to the repositories. One repository per line.
  6. Press the Save button.

Searching across repositories you’ve added to Sourcegraph with search contexts

Once you’ve added repositories to Sourcegraph, you can search across those repositories by default using search contexts.

Sourcegraph Cloud supports two search contexts:

  • Your personal context, context:@username, which automatically includes all repositories you add to Sourcegraph.
  • The global context, context:global, which includes all repositories on Sourcegraph Cloud.

Coming soon: create your own search contexts that include the repositories you choose. Want early access to custom search contexts? Let us know.