1

I usually add the files and extensions that I want to ignore to .git/info/exclude to have a rather neat repository. I'm on a mac and for example I always need to exclude the .DS_Store file that is created. I was wondering if there is a way to change the default exclude file.

aljabadi
  • 463
  • 4
  • 16
  • 4
    Check .gitignore : https://git-scm.com/docs/gitignore – Sid Oct 17 '18 at 12:10
  • Also : https://stackoverflow.com/questions/4621072/git-ignore-all-files-of-a-certain-type-except-those-in-a-specific-subfolder – Sid Oct 17 '18 at 12:11
  • 1
    If you mean ignoring the folder for all repositories, try this: https://stackoverflow.com/questions/7335420/global-git-ignore – Kevin Hoerr Oct 17 '18 at 13:04
  • @KevinHoerr Thanks. That is exactly what I meant. So that any new repository made will automatically ignore certain files. – aljabadi Oct 18 '18 at 00:07
  • Possible duplicate of [Global Git ignore](https://stackoverflow.com/questions/7335420/global-git-ignore) – phd Oct 18 '18 at 13:49

2 Answers2

0

Use * and other operators for pattern matching. See this link for more info. For .DS_Store you can add the following to .gitignore .

**/.DS_Store

For Ignoring all pdf files you can add:

**/*.pdf

Hope it helps !!

Rishabh Agarwal
  • 1,988
  • 1
  • 16
  • 33
  • 1
    Thanks but I was after an automatic way for any new repo to include this pattern in the exclude file. – aljabadi Oct 18 '18 at 00:08
0

Create .gitignore_global file somewhere, for example user directory is a good place. Add all files and directories you want to ignore locally. Then you need to tell git where is this file by using this command:

$ git config --global core.excludesfile <your-git-ignore-file>

if you are put the file in user directory, then command could be this in windows:

$ git config --global core.excludesfile ~/.gitignore_global
Aryan Firouzian
  • 1,940
  • 5
  • 27
  • 41