Skip to content

Commit 06267a7

Browse files
committed
Ignore only root target directory
We used to ignore all target directories, because it was common to have multiple packages with different target directories in a single repository. Now, when workspaces are here, such setups usually have a single target, and we can .gitignore only it. It's useful because sometimes you want to have a module named `target` in Rust. If you use non-workspaced multi-package setup, you can create a .gitignore with `/target/` for each package.
1 parent 381a4e7 commit 06267a7

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/cargo/ops/cargo_new.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ fn mk(config: &Config, opts: &MkOptions) -> CargoResult<()> {
384384
let path = opts.path;
385385
let name = opts.name;
386386
let cfg = global_config(config)?;
387-
let ignore = ["target/\n", "**/*.rs.bk\n",
387+
let ignore = ["/target/\n", "**/*.rs.bk\n",
388388
if !opts.bin { "Cargo.lock\n" } else { "" }]
389389
.concat();
390390

0 commit comments

Comments
 (0)