git官网上关于.gitignore的部分的简要翻译
2016-11-20 23:20
363 查看
简略的翻译了git官网上关于.gitignore的部分,点击查看原文
A blank line matches no files, so it can serve as a separator for readability.
一个空行不匹配任何文件,只当做是分隔的作用
A line starting with # serves as a comment. Put a backslash ("
以“#”开头的是注释行。“\”放在表达式前面用来转义
Trailing spaces are ignored unless they are quoted with backslash ("
行尾的空格会被忽略,除非在空格前加“\”才会生效
An optional prefix "
“!”前缀选项:否定模式,即已经被前面ignore表达式匹配后忽略的文件,重新被包含进git。
但是,如果此文件的父目录已经被忽略了,那么此文件就不能再重新包含进git,因为处于性能的考虑。git并不会去检索被忽略的目录,所以.gitignore里面的表达式并不会去匹配这些目录下的文件;
放一个“\”在“!”前面可以转义“!”为一个简单的字符(即失去了否定模式的功能)
\!file!.txt 匹配文件“!file!.txt”,第一个“!”位于行首,被转义为简单的字符,第二个“!”就是个简单的字符,因为“!”只有放在行首才拥有否定模式的效果
If the pattern ends with a slash, it is removed for the purpose of the following description, but it would only find a match with a directory. In other words,
表达式以“/”结尾的话,只会匹配目录;
例如“foo/”将只会匹配foo目录和目录里面所有东西,但不会匹配foo文件和foot软连接
If the pattern does not contain a slash /, Git treats it as a shell glob pattern and checks for a match against the pathname relative to the location of the
如果表达式里面没有“/”,那么git会把表达式当做shell表达式去匹配和.gitignore同级目录下的文件(对于那些不是在.gitignore文件里的表达式,会相对于工作目录去查找),git命令也可以设置ignore表达式
Otherwise, Git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will not match a / in the pathname. For example, "Documentation/*.html" matches "Documentation/git.html" but not "Documentation/ppc/ppc.html" or "tools/perf/Documentation/perf.html”.
通配符“*”不会匹配路径字符串中的“/”,
"Documentation/*.html" 匹配 "Documentation/git.html”
但不匹配"Documentation/ppc/ppc.html" 或者 "tools/perf/Documentation/perf.html”.
A leading slash matches the beginning of the pathname. For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c”.
“/”开头的只匹配当前目录下的东西;
“/*.c”匹配“cat-file.c”,但不匹配“hello/sha.c”
Two consecutive asterisks ("
A leading "
A trailing "
A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, "
Other consecutive asterisks are considered invalid.
连续的两个星号“**”能匹配完整的路径,但会有些特殊的意思:
以“**”开头,紧跟着一个“/”会在所有目录下去匹配;例如“**/foo”会匹配任何 叫foo的目录或文件,效果等同于表达式“foo”;"**/foo/bar" 会匹配任何位于foo目录下,名为”bar”的目录或文件 (即foo目录可以再任何地方)。
“/**”会匹配目录下的任何东西;例如“abc/**”,会匹配“abc”目录下的所有文件,不限目录深度,但是“abc”目录的位置必须和“.gitignore”同级。(经过测试,凡是此种“name/**”格式,即以“/**”或者“/*”结尾的,都会限制只在.gitignore同级目录下搜索name文件夹)
“/**/”匹配0层或多层目录,例如,"
其他形式的“**”被认为是无效的
To stop tracking a file that is currently tracked, use git rm --cached.
§NAME
gitignore - Specifies intentionally untracked files to ignore§SYNOPSIS
$HOME/.config/git/ignore, $GIT_DIR/info/exclude, .gitignore§DESCRIPTION
略,点击查看原文§PATTERN FORMAT
.gitignore文件里表达式的一些用法:A blank line matches no files, so it can serve as a separator for readability.
一个空行不匹配任何文件,只当做是分隔的作用
A line starting with # serves as a comment. Put a backslash ("
\") in front of the first hash for patterns that begin with a hash.
以“#”开头的是注释行。“\”放在表达式前面用来转义
Trailing spaces are ignored unless they are quoted with backslash ("
\”).
行尾的空格会被忽略,除非在空格前加“\”才会生效
An optional prefix "
!" which negates the pattern; any matching file excluded by a previous pattern will become included again. It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined. Put a backslash ("
\") in front of the first "
!" for patterns that begin with a literal "
!", for example, "
\!important!.txt”.
“!”前缀选项:否定模式,即已经被前面ignore表达式匹配后忽略的文件,重新被包含进git。
但是,如果此文件的父目录已经被忽略了,那么此文件就不能再重新包含进git,因为处于性能的考虑。git并不会去检索被忽略的目录,所以.gitignore里面的表达式并不会去匹配这些目录下的文件;
放一个“\”在“!”前面可以转义“!”为一个简单的字符(即失去了否定模式的功能)
\!file!.txt 匹配文件“!file!.txt”,第一个“!”位于行首,被转义为简单的字符,第二个“!”就是个简单的字符,因为“!”只有放在行首才拥有否定模式的效果
If the pattern ends with a slash, it is removed for the purpose of the following description, but it would only find a match with a directory. In other words,
foo/will match a directory
fooand paths underneath it, but will not match a regular file or a symbolic link
foo(this is consistent with the way how pathspec works in general in Git).
表达式以“/”结尾的话,只会匹配目录;
例如“foo/”将只会匹配foo目录和目录里面所有东西,但不会匹配foo文件和foot软连接
If the pattern does not contain a slash /, Git treats it as a shell glob pattern and checks for a match against the pathname relative to the location of the
.gitignorefile (relative to the toplevel of the work tree if not from a
.gitignorefile).
如果表达式里面没有“/”,那么git会把表达式当做shell表达式去匹配和.gitignore同级目录下的文件(对于那些不是在.gitignore文件里的表达式,会相对于工作目录去查找),git命令也可以设置ignore表达式
Otherwise, Git treats the pattern as a shell glob suitable for consumption by fnmatch(3) with the FNM_PATHNAME flag: wildcards in the pattern will not match a / in the pathname. For example, "Documentation/*.html" matches "Documentation/git.html" but not "Documentation/ppc/ppc.html" or "tools/perf/Documentation/perf.html”.
通配符“*”不会匹配路径字符串中的“/”,
"Documentation/*.html" 匹配 "Documentation/git.html”
但不匹配"Documentation/ppc/ppc.html" 或者 "tools/perf/Documentation/perf.html”.
A leading slash matches the beginning of the pathname. For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c”.
“/”开头的只匹配当前目录下的东西;
“/*.c”匹配“cat-file.c”,但不匹配“hello/sha.c”
Two consecutive asterisks ("
**") in patterns matched against full pathname may have special meaning:
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".
A trailing "
/**" matches everything inside. For example, "
abc/**" matches all files inside directory "
abc", relative to the location of the
.gitignorefile, with infinite depth.
A slash followed by two consecutive asterisks then a slash matches zero or more directories. For example, "
a/**/b" matches "
a/b", "
a/x/b", "
a/x/y/b" and so on.
Other consecutive asterisks are considered invalid.
连续的两个星号“**”能匹配完整的路径,但会有些特殊的意思:
以“**”开头,紧跟着一个“/”会在所有目录下去匹配;例如“**/foo”会匹配任何 叫foo的目录或文件,效果等同于表达式“foo”;"**/foo/bar" 会匹配任何位于foo目录下,名为”bar”的目录或文件 (即foo目录可以再任何地方)。
“/**”会匹配目录下的任何东西;例如“abc/**”,会匹配“abc”目录下的所有文件,不限目录深度,但是“abc”目录的位置必须和“.gitignore”同级。(经过测试,凡是此种“name/**”格式,即以“/**”或者“/*”结尾的,都会限制只在.gitignore同级目录下搜索name文件夹)
“/**/”匹配0层或多层目录,例如,"
a/**/b" 匹配 "
a/b", "
a/x/b", "
a/x/y/b”
其他形式的“**”被认为是无效的
§NOTES
The purpose of gitignore files is to ensure that certain files not tracked by Git remain untracked.To stop tracking a file that is currently tracked, use git rm --cached.
相关文章推荐
- 翻译语音天使 voiceangel 控件 关于判断呼叫状态部分的说明
- 一篇关于Unity3D优化的文章,翻译脚本优化部分 (2011-11-27 11:26:28)
- 关于gitignore文件,Myeclipse和IDEA的编译输出文件的问题
- 关于git、github和.gitignore的一些事
- 关于.gitignore中!使用的注意事项
- 关于dnn图书翻译的索引部分的讨论(参加翻译工作的朋友请进)
- 关于git的命令行提交、下载代码简要步骤
- 关于配置git忽略文件夹中部分文件的问题
- GitHub gitignore官方文档翻译
- stevens那本socket的第一部分的简要翻译
- Android Audio音频部分官网文档中文翻译
- 20131007-STM8L101F3P6关于硬件IIC写时序和勘误部分的翻译
- jekyll 官网文档部分翻译
- Sun JNDI教程翻译 第三部分 关于Names
- 关于gitignore文件的创建与使用
- 一篇关于Unity3D优化的文章,翻译脚本优化部分
- 关于git的.gitignore无法忽略某些文件解决方法
- unity3d官网手册翻译——(脚本部分)用组件控制物体
- caffe官网的部分翻译及NG的教程
- 关于使用Github,gitignore不起作用的解决方法