0

I would like to ignore sandbox directories located in my project directory. However, by default, if there are some same directory that can be always ignored w/o any configuration, I would love to use and should use it.

So, my question is Is there any git directory that can be definitely and always ignored by default?

diveintohacking
  • 4,783
  • 6
  • 29
  • 43

1 Answers1

1

You can create a global .gitignore:

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

for instance; see Global Git ignore for much more about this.

Note, however, that in many cases, you should not do this. (This same idea is captured in the second answer on that page, which is not the accepted answer.)

For files that are created by something you do, that won't be created for other people doing work in the same project, a global .gitignore is appropriate. For instance, suppose that all of your coworkers use the vim or emacs or sublime editor, but you use your own personal editor, perhaps called Frank's Editor, and it creates backup files named .frank.<name>.

You would want all your Git repositories to ignore .frank.* as those are your editor backups. They're not Bob's editor backups, which are *.~ because he uses emacs, and they're not Carol's .*.swp vim temporaries. Your project shouldn't ignore *.~ either—that should be in Bob's global ignore, and Carol should have .*.swp in her global ignore.

But if your project has a sandbox/ subdirectory that the project uses, that you, Bob, and Carol will all have in your project—well, that file-name should be in the project's .gitignore file, so that it's ignored in your clone, in Bob's clone, in Carol's clone, and in every other clone anyone ever makes, because that project's .gitignore gets cloned along with the project.

torek
  • 448,244
  • 59
  • 642
  • 775