How to prevent `git checkout` from checking out specific file types?

时间:2015-06-25 18:36:22

标签: git gitignore ignore msysgit git-checkout

We are creating a system in which users will be able to push arbitrary content to a shared Git repository. Our server will then checkout the repository and use the files.

To reduce risks, I'd like the git checkout command not to write any .exe, .cmd, .bat etc. on disk, and control which file types will be written.

How to configure Git (either using a configuration file, or a command-line argument) to ignore/skip specific file types at checkout?

Note that I'm running Git for Windows.

1 个答案:

答案 0 :(得分:1)

我首先想到的是使用涂抹过滤器,您可以将其指定为gitattributes文件(Customizing Git - Git Attributes)的一部分。

或者,如果你想首先防止这些文件被提交,可能是你的git服务器上放置一个pre-recieve钩子(Git hooks)。