Ignoring extra files in git

Hello everyone. I started to study Rust recently. I have a question, when I compile my program, in addition to the executable file, many other files are created. I'm using cargo new to create a new project. Here is an example of what files the git sees:
./variables/target/rls/debug/incremental/variables-1wijjhv4oppb1/s-fx4rdur1rb-8xq61i-em4kj10p5wp3/
../variables/target/rls/debug/incremental/variables-1wijjhv4oppb1/s-fx4rdur1rb-8xq61i.lock
../variables/target/rls/debug/incremental/variables-285ovvyga72hb/s-fx4rdxllxg-14qu9kg-1zbpep99t53t6

How do I tell git ignore the types of these files, I'm a little confused about what to do with them and what they are for. I started a "home" github account and publish my projects there. Sometimes these files are annoying. What are they needed for?

To ignore these files, you should create a .gitignore file and place it in the same folder as where the target/ folder is located. Then add a line to the file containing target to ignore the folder.

1 Like

@alice Thank you very much for your help, everything works :slight_smile: