Repo specific ignore files in git

2019-01-25 19:48发布

问题:

Is it possible to have repo specific .gitignore files? Eg:

[origin] .gitignore:

  • foo1.*
  • foo2.*

[another] .gitignore:

  • bar1.*
  • bar2.*

The purpose behind this is that we deploy using git on to a managed cloud service and we'd like to keep dev files in version control but not push them to a repo.

回答1:

Yes, you can put per repository ignore patterns in .git/info/exclude in each repository.

(Note, this only affects what is ignored in each repository, it won't affect files that you actively place under source control and the push. I'm not completely clear on your desired use case.)



回答2:

Yes you can, just can't have them in the same folder. If you create a new folder, day "deploy" and publish your deploy data there, it will use the .gitignore in that folder (not the root one).



回答3:

You could probably do this using git hooks (the scripts in .git). post-checkout sounds good.



标签: git gitignore