Skip to content

Change the /target line in .gitignore generated by cargo new to /**/target #6245

@jamesray1

Description

@jamesray1

Describe the problem you are trying to solve

Ignore all target directories within a directory at infinite depth with cargo new. This is useful as projects grow, without manually needing to add target directories to .gitignore, or developers figuring out how to fix many files being added in a target directory with pull requests. At the moment the generated file for .gitignore with cargo new hi is as shown:

[jray@jr-dl r]$ cargo new hi
     Created binary (application) `hi` project
[jray@jr-dl r]$ cd hi
[jray@jr-dl hi]$ cat .gitignore
/target
**/*.rs.b

Describe the solution you'd like

Change the /target line above to /**/target, similar to github/gitignore#2866.

Notes

Similar to #2565.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions