Cargo Install a Package from a Specific Commit, Branch, or Tag

In Cargo.toml, you’ll just need a little exta config in the desired [dependencies] section.

Installing a package from GitHub has the Cargo.toml config of:

[dependencies]
slack = { git = "https://github.com/LyleScott/slack-rs.git" }

Along with specifiying the git URI for the package, you may also include a key of branch, tag, or rev (revision; the commit hash). Without any of these (ie, just git), the latest commit on the master branch is used.

Annoyingly, I get a warning in my IDE if I introduce a line break for rev.

[dependencies]
slack = { git = "https://github.com/LyleScott/slack-rs.git", rev = "d433b65d116c9305844e51f1a45309b6c47e0799" }

If you are using [dependencies.app] syntax, then it should look something like:

[dependencies.app]
git = "https://github.com/LyleScott/slack-rs.git"
# Pick one... (rev is commit hash)
branch = ""
tag = ""
rev = ""