The Sourcegraph CLI (src)
provides the command src serve-git
which will recursively serve up the git repositories it finds in the current directory. It exposes the repositories over HTTP as well as an API for Sourcegraph to query.
The most common use-case for src serve-git
is to create git repos that do not exist on a code host for Sourcegraph. For example:
git p4
to serve up Perforce repositories.src
).src serve-git
in a directory with git repositories. Ensure the address is reachable by Sourcegraph.src serve-git
.IMPORTANT: If you are running Sourcegraph in docker and are using a Linux host machine, replace host.docker.internal
in the above with the IP address of your actual host machine because host.docker.internal
does not work on Linux. You should use the network-accessible IP shown by ifconfig
(rather than 127.0.0.1 or localhost).
src-cli publishes Docker images which can be used instead of the binary. For example to publish your current directory run:
docker run \ --rm=true \ --publish 3434:3434 \ --volume $PWD:/data/repos:ro \ sourcegraph/src-cli:latest serve-git /data/repos
To confirm this is working visit http://localhost:3434
Before Sourcegraph 3.19 we recommend users to still use src-expose
.