Search code examples
gitgitignore

Configure git not to use ".gitignore" but "gitignore"


For reasons that do not add anything to this question1, I would like to know whether it is possible to configure git to use gitignore instead of .gitignore.

A similar situation is having git instead of .git as the git working dir of a repository, which can be easily accomplished by adding the line

gitdir: ./git

to a .git file living at the root folder of the project. Hence I wonder whether it is possible to tell git not to use .gitignore but another file to contain the rules for files and folders that need not to be tracked.

There are similar questions suggesting the use of $GIT_DIR/info/exclude as a solution. Even though this leverages in practice the same mechanisms used by the gitignore file, my question is whether the actual .gitignore could be assigned to be some other file.


1 For the curious reader: I sync my personal machines, but I do not want to sync hidden files and folders since I like to have different configuration files on different machines. Still, I would like my git repositories to be in sync with the minimum possible effort. This is something I only do with my own projects, where I am often the only contributor -- so please let us not discuss bad and good practices of git usage, and instead keep the focus on the actual question :)


Solution

  • You should be able to change the ignore file by entering the following:

    git config core.excludesFile gitignore