我是靠谱客的博主 慈祥山水,最近开发中收集的这篇文章主要介绍git .gitignoreno .a filesbut do track lib.a, even though you're ignoring .a files aboveonly ignore the TODO file in the current directory, not subdir/TODOignore all files in the build/ directoryignore doc/notes.txt, but not doc/server/arch.txtignore ,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

2019独角兽企业重金招聘Python工程师标准>>> hot3.png

忽略文件 一般我们总会有些文件无需纳入 Git 的管理,也不希望它们总出现在未跟踪文件列表。 通常都是些自动生成的文件,比如日志文件,或者编译过程中创建的临时文件等。 在这种情况下,我们可以创建一个名为 .gitignore 的文件,列出要忽略的文件模式。 来看一个实际的例子: $ cat .gitignore *.[oa] *~ 第一行告诉 Git 忽略所有以 .o 或 .a 结尾的文件。一般这类对象文件和存档文件都是编译过程中出现的。 第二行告诉 Git 忽略所有以波浪符(~)结尾的文件,许多文本编辑软件(比如 Emacs)都用这样的文件名保存副本。 此外,你可能还需要忽略 log,tmp 或者 pid 目录,以及自动生成的文档等等。 要养成一开始就设置好 .gitignore 文件的习惯,以免将来误提交这类无用的文件。 文件 .gitignore 的格式规范如下:

所有空行或者以 # 开头的行都会被 Git 忽略。

可以使用标准的 glob 模式匹配。

匹配模式可以以(/)开头防止递归。

匹配模式可以以(/)结尾指定目录。

要忽略指定模式以外的文件或目录,可以在模式前加上惊叹号(!)取反。 所谓的 glob 模式是指 shell 所使用的简化了的正则表达式。 星号()匹配零个或多个任意字符;[abc] 匹配任何一个列在方括号中的字符(这个例子要么匹配一个 a,要么匹配一个 b,要么匹配一个 c);问号(?)只匹配一个任意字符;如果在方括号中使用短划线分隔两个字符,表示所有在这两个字符范围内的都可以匹配(比如 [0-9] 表示匹配所有 0 到 9 的数字)。 使用两个星号() 表示匹配任意中间目录,比如a/**/z 可以匹配 a/z, a/b/z 或 a/b/c/z等。

我们再看一个 .gitignore 文件的例子:

no .a files

*.a

but do track lib.a, even though you're ignoring .a files above

!lib.a

only ignore the TODO file in the current directory, not subdir/TODO

/TODO

ignore all files in the build/ directory

build/

ignore doc/notes.txt, but not doc/server/arch.txt

doc/*.txt

ignore all .pdf files in the doc/ directory

转载于:https://my.oschina.net/u/563488/blog/677334

最后

以上就是慈祥山水为你收集整理的git .gitignoreno .a filesbut do track lib.a, even though you're ignoring .a files aboveonly ignore the TODO file in the current directory, not subdir/TODOignore all files in the build/ directoryignore doc/notes.txt, but not doc/server/arch.txtignore 的全部内容,希望文章能够帮你解决git .gitignoreno .a filesbut do track lib.a, even though you're ignoring .a files aboveonly ignore the TODO file in the current directory, not subdir/TODOignore all files in the build/ directoryignore doc/notes.txt, but not doc/server/arch.txtignore 所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(52)

评论列表共有 0 条评论

立即
投稿
返回
顶部