Due to external weird constraints I cannot modify the .gitignore of my repository. Is there a way to ignore files and directories other than modifying a .gitignore? Even if it is a global solution like a global configuration that will be applied to all my repositories.
If you can modify .git/info/exclude
you can put the same rules there. But that file is within your local repo only.
Other than committing files individually, I don't think so. You could come up with some kind of globber that honored your own ignore and passed desirables through an exec or pipe when committing, other than that .. I don't think you have many options. I believe git's 'exclude' also applies when pulling, which might get messy.
There are three ways to tell GIT which files to ignore:
- .gitignore files
- $GIT_DIR/.git/info/exclude
- Files pointed to via the
core.excludesfile
setting
The latter two points could solve your problem.
For further information, see gitignore(5).
Do not forget, according to gitignore, that there is an order of precedence in the different "ignore pattern sources" that Git consider:
- Patterns read from the command line for those commands that support them.
- Patterns read from a .gitignore file in the same directory as the path, or in any parent directory, with patterns in the higher level files (up to the root) being overridden by those in lower level files down to the directory containing the file.
- Patterns read from $GIT_DIR/info/exclude.
- Patterns read from the file specified by the configuration variable core.excludesfile.
The last two can be a solution for your problem but:
- they are not replicated for a distant repository
- they can have their patterns overridden by the other sources
(See also this SO question)