Skip to content

Instantly share code, notes, and snippets.

@kestein
Last active March 28, 2024 10:36
Show Gist options
  • Star 15 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kestein/87d8bb9cef187c0d02d733138a0a4454 to your computer and use it in GitHub Desktop.
Save kestein/87d8bb9cef187c0d02d733138a0a4454 to your computer and use it in GitHub Desktop.
Linking to a private repo in Cargo.toml

Under the dependencies section, put

<crate name>={git="ssh://git@github.com/<organization>/<reponame>.git"}

It is pretty similar to a github repo's ssh cloning link, however the : is replaced with a / and ssh:// is prepended to the URL.

git@github.com:my-organization/my-repo.git vs ssh://git@github.com/my-organization/my-repo.git

The SSH URL needs to be used because Cargo is currently unable to handle the authentication prompt that comes up when an HTTPS link is used.
Make sure that the matches the crate name in the target repo's Cargo.toml. The repo name will not override what is in the Cargo.toml if it is a different value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment