Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use global gitignore with Visual Studio Code?

I have a global gitignore file defined in my gitconfig but Visual Studio Code seems to not be interpreting it. How would I use a global gitignore with Visual Studio Code?

like image 601
Darren Avatar asked Jul 26 '17 17:07

Darren


Video Answer


2 Answers

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.

like image 117
Ulysse BN Avatar answered Sep 18 '22 10:09

Ulysse BN


This steps to Windows:

  1. Open GitBash Terminal
  2. Run touch ~/.gitignore_global to create a global .gitignore file in the home directory
  3. Edit file in your home directory: ~/.gitignore_global
  4. Add .vscode/ and any other files or directories that you want to ignore and not include in project-specific .gitignore files;
  5. Save file;
  6. 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.

like image 35
Max Avatar answered Sep 20 '22 10:09

Max