Search code examples
rustversion-control

Which files should I be putting in my GitHub Repository


I'm making a GitHub repository for my rust project but there are a lot of files, so I was just wondering:

Which files should I be putting in the repository and which ones should I absolutely make sure aren't in the repository?

I've tried searching it up but I just couldn't find anything.


Solution

  • Files that definitely need to be included:

    • Cargo.toml
    • src/

    Files that need to be included if you have them:

    • build.rs

    Files that should be included in most circumstances:

    • Cargo.lock
    • .gitignore

    Files that should be included if you have them:

    • README.md, LICENSE.md, etc.
    • rustfmt.toml
    • .cargo/
    • rust-toolchain.toml
    • examples/
    • tests/
    • benches/

    Files that should not be included:

    • target/

    By default, if you create a project with cargo new or cargo init, Cargo will generate a .gitignore file so you don't need to do anything special.

    # .gitignore
    /target
    

    Generally, Rust will put any files that need ignoring in target/, but of course, if you have non-Rust files that need ignoring, you can add them to .gitignore.