Sometimes you need to use a custom fork of an Elixir dependency—whether to apply a bug fix, test new features, or modify behaviour. Thankfully, Elixir’s mix tool makes this easy using Git dependencies.

Point to the Git Repository

In your mix.exs, update the deps/0 function to use the :git option:

defp deps do
  [
    {:my_dep, git: "https://github.com/your_username/your_fork.git"}
  ]
end

Pin to a branch, tag, or commit

To avoid unexpected updates, you can specify a particular version. You can point to a branch, tag or commit.

Branch

{:my_dep, git: "https://github.com/your_username/your_fork.git", branch: "main"}

Tag

{:my_dep, git: "https://github.com/your_username/your_fork.git", tag: "v0.1.0"}

Commit

{:my_dep, git: "https://github.com/your_username/your_fork.git", ref: "abc1234"}

Fetch the dependency

Simply run deps.get and you'll see that it now fetches the fork instead:

mix deps.get

Your Elixir app will now use the custom fork instead of pulling from Hex.