1

Is it possible to have the functionality of .gitignore files if I have a directory with multiple git projects?

I manage things like .bashrc and .vimrc on different git projects by renaming the .git directory to something like .git-bashrc, which are located on the same parent directory. This means I can't have a .gitignore file for each of my projects.

Is it possible to rename .gitignore files, or maybe place them in the git directory of the project?

Fábio Queluci
  • 311
  • 1
  • 2
  • 15

1 Answers1

1

You can have multiple .gitignore files in different (sub)directories for your different projects. The name must be .gitignore, nothing else. See this topic for more info..

Community
  • 1
  • 1
balazs630
  • 3,421
  • 29
  • 46
  • Wouldn't putting .gitignore on a subdirectory mean it can only handle files on that same subdirectory? I'm dealing with project files that must stay in my home directory, so I can't move them to a subdirectory alongside .gitignore. – Fábio Queluci Jan 23 '17 at 17:30
  • You have a global gitignore file with your git installation. Everything written here is applied to all of the the git repos you have. In additon you can create local .gitignore files and put them in specified folders where you want to define ignore rules. My recommendation is to put the common ignore rules in the global gitignore file - which applies to every git repo - and create local .gitignore files for each of your projects with only the specific ignore rules related that project. – balazs630 Jan 24 '17 at 11:54
  • Hi @balazs630 any recommendation on how to use the same `.gitignore` file across multiple git projects and at the same time have that common `.gitignore` file in a separate config folder which is itself present in GitHub(so that same config can be shared with others team members) – AndroidEngineX Feb 22 '23 at 20:38