Add a [patch] section to your Cargo.toml file to override a dependency with a local path or git repository. This tells Cargo to ignore the version on crates.io and use your specified source instead.
[patch.crates-io]
serde = { path = "../my-local-serde" }
# or
# serde = { git = "https://github.com/your-org/serde", branch = "main" }
Run cargo build to apply the override. Cargo will now compile your project using the patched version of serde instead of the one from crates.io.