Customizing gitignore

I'm just now learning Rust and one of the first things I notice is that I have to edit .gitignore every time I build a new project, to include Vim's artifacts (*~, etc.). I'd like to make my own standard .gitignore that includes those and other common changes without my manual intervention every time. I can't be the first person who wants to do that, but I can't find any google-trace of its being explained in public. Is there a place I can go to learn how to do that?

Welcome Daryl!

One way I do it is via the cargo init command instead of cargo new. The typical flow is:

mkdir foo_project
cd foo_project
cp my.gitignore.template .gitignore # And more such files
git init
cargo init # It patches existing .gitignore if any and does not override it

I have all these as a bash alias in .bashrc so it is not as tedious. Though, I'd be happy to hear a somewhat more "out-of-the-box" solution for this.


I personally always set up a global gitignore for these kinds of things, so I never end up really modifying new ones. That might work for you too!


I tried both approaches. The global gitignore has more, well, global application to git in general, and the scripted "cargo init" approach looks like I'll be able to use it for other Cargo customizations, as well. Thanks and kudos to both @osrust and @steveklabnik!


This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.