Should sub-crates have a .git?

The default for cargo new is to generate a .git and .gitignore for every new crate, but I see a lot of projects that use workspaces only have .git at the root directory so I'm not sure which is preferred.

When you put multiple crates in a workspace, the idea is generally that they're parts of some larger unit of functionality for which using multiple crates happened to be useful for one reason or another.
As such, it only makes sense to put everything in a single git repo, since putting the crates in multiple repos just makes the entire thing harder to work with e.g. when committing, or even cloning the repos.

2 Likes

Gotcha, thank you. Is there a way to make it so that cargo new doesn't init git in a workspace?

cargo new --vcs none
cargo new --help
1 Like

cargo new already avoids creating .git directories when already in a git repo.

2 Likes

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.