有没有办法使用 git ignore 文件
忽略所有文件名中带有 test 的文件?
我的文件看起来像这样:
- css/test.css
- js/subfolder/test.js
- lib/main/sub/test.html
等等还有其他内容。
我希望 git
避免添加或提交任何名为 test 的文件。
来自Git文档
A leading "**" followed by a slash means match in all directories. For
example, "**/foo" matches file or directory "foo" anywhere, the same
as pattern "foo". "**/foo/bar" matches file or directory "bar"
anywhere that is directly under directory "foo".
对于你的情况:
**/[Tt]est*
它还可以匹配大小写字母。
*
是什么作用? - clabe45test.json
、test.py
、testosterone
、testimony.txt.jpg.zip
甚至只有test
。你可以尝试使用带有句点的**/[Tt]est.*
,虽然这样做无法捕获像testClient.js
这样的文件。 - Mark Peschel使用test*
更新.gitignore
另外,阅读此文以获取更多信息。
**/..
。链接也没有提到这两个星号。在基本目录中,test*
只忽略了它。 - Timoman gitignore
中,以两个星号(**)开头并跟着一个斜杠意味着匹配所有目录。例如,"/foo"匹配任何位置的文件或目录"foo",与模式"foo"相同。"/foo/bar" 匹配直接位于目录"foo"下的文件或目录"bar",无论它在什么地方。 - user2453382尝试将该模式添加到 .gitignore 文件中,模式为 test.*
添加后,使用像你上面提到的一些文件进行 git 状态检查。
如果正常工作,则无需更改。
man gitignore
жқҘеҫ—еҲ°зӯ”жЎҲпјҢе…¶дёӯеҢ…еҗ«дәҶиҜӯжі•жҸҸиҝ°е’ҢдёҖдәӣе°ҸдҫӢеӯҗгҖӮ - Cascabel