Git Tricks

I will be constantly updating this post for new tricks I learnt about Git. :)

Auto .gitignore for Every Repo!

If you like to set up git repos for every random node.js experiments you do, having to add a .gitignore file to your repo every time can become a tedious task. is a great site to generate .gitignore files tailored for your projects, and they have a simple “CLI” to save the time you copy and paste from a browser. Just go to and follow the instructions.

Assuming you are using ZSH, you can also bind all those steps with this one-liner:

# better "gi"
echo "function gi() { git init && curl -L -s\$@ >> .gitignore; }" >> ~/.zshrc && source ~/.zshrc

Now you can use gi linux,macos,windows,node to initialize repos for your node.js experiments!

Grepping with Git Grep

grep is super useful to search for text or patterns. The problem with running grep directly onto a project directory is that all files will be included in the search - all cache files and if you are using node, also your huuuge node_modules directory.

git grep ignores all those files defined in .gitignore for you - use it instead of original grep!