.gitignore文件中路径的不同? [英] Difference in the paths in .gitignore file?

查看:77
本文介绍了.gitignore文件中路径的不同?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用git,但对 .gitignore 文件路径仍然感到困惑.

I've been using git but still having confusion about the .gitignore file paths.

那么, .gitignore 文件中以下两个路径之间有什么区别?

So, what is the difference between the following two paths in .gitignore file?


tmp/*
public/documents/**/*

我知道tmp/*将忽略其中的所有文件和文件夹.我对吗? 但是第二行路径是什么意思?

I can understand that tmp/* will ignore all the files and folders inside it. Am I right? But what does that second line path mean?

推荐答案

这取决于shell的行为. Git并没有做任何工作来确定如何扩展它们.通常,*与任何单个文件或文件夹匹配:

This depends on the behavior of your shell. Git doesn't do any work to determine how to expand these. In general, * matches any single file or folder:

/a/*/z
 matches        /a/b/z
 matches        /a/c/z
 doesn't match  /a/b/c/z

**匹配任何文件夹字符串:

** matches any string of folders:

/a/**/z
 matches        /a/b/z
 matches        /a/b/c/z
 matches        /a/b/c/d/e/f/g/h/i/z
 doesn't match  /a/b/c/z/d.pr0n

*组合**以匹配整个文件夹树中的文件:

Combine ** with * to match files in an entire folder tree:

/a/**/z/*.pr0n
 matches        /a/b/c/z/d.pr0n
 matches        /a/b/z/foo.pr0n
 doesn't match  /a/b/z/bar.txt

这篇关于.gitignore文件中路径的不同?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆