How can I tell Git to use a different gitignore file than “.gitignore”?

后端 未结 3 1833
囚心锁ツ
囚心锁ツ 2021-01-19 01:17

I can tell Git where the Git repository is with --git-dir. I can tell Git where the working tree is with --work-tree. How do I tell Git where the g

3条回答
  •  长情又很酷
    2021-01-19 02:07

    You can use core.excludesfile to specify the new ignore file. By default this will only affect the current repository; you can use the --global option if you want to change the default value.

    git config core.excludesfile ".new_gitignore"
    

    Edit 1

    AFAIK, .gitignore cannot be disabled. And it takes precedence over .git/info/excludes and core.excludesfile. The only way I can think of is having some hacks using filters. This answer explains the use of filters well.

提交回复
热议问题