How to use global gitignore with Visual Studio Code?
EDIT: Comment from Piyush Soni.
As of 9 august 2021, for this configuration to work, you also have to check useIgnoreFiles
, hence:
"search.useGlobalIgnoreFiles": true,
"search.useIgnoreFiles": true
You have to add these in your settings to allow global gitignore:
"search.useGlobalIgnoreFiles": true
Found on Microsoft/vscode#59364.
For this to work, I also had to restart my VSCode session.
Note that you must already have a global ignore file if you want it to be useful. You can set or see which one is set with the next commands:
# get
git config --global core.excludesFile
# set
git config --global core.excludesFile <filename>
See more details about gitignore on the git documentation.
I know this thread is several months old but the correct answer for this, today, is to open settings in Code and search for "git" and then check the box "Use Global Ignore Files".
Of course, you can add it manually too, but no need for that now as it has been added in settings.
This steps to Windows:
- Open GitBash Terminal
- Run touch ~/.gitignore_global to create a global .gitignore file in the home directory
- Edit file in your home directory: ~/.gitignore_global
- Add .vscode/ and any other files or directories that you want to ignore and not include in project-specific .gitignore files;
- Save file;
- In GitBash run git config --global core.excludesfile ~/.gitignore_global
Done! That’s it! Using .gitignore_global will let you customize your editor without having to edit and commit changes to the .gitignore file for every single project.