Home

Creating a global gitignore file

I have been watching a tutorial lately, and was suprised how the instructor managed to exclude node_modules folder without any .gitignore file in the repo. Later I have figured out how to make this possible by declaring a global gitignore file.

Create a global exclude file in the folder ~

On Mac, you can use touch to create it:

touch ~/.gitignore_global

If you are using VS Code you can run following command to create the file and open it in VS Code

code ~/.gitignore_global

Open your Git Bash and run the following command:

git config --global core.excludesfile ~/.gitignore_global

The file name here can be anything. For example, you can use .global_gitignore or .gitignore instead of .gitignore_global.

That's it you have created the global gitignore file and added it to global git config.

Now you can customise the .gitignore_global as you like.

node_modules/

Further reading



Last Updated on

Next Post: Rules vs Guidelines →

Comments