[英]Git: how to ignore hidden directories?
I'd like to have Git ignore all hidden files and directories, ie .aptitude
, .ssh/
and .bash_rc
. 我想让Git忽略所有隐藏的文件和目录,即
.aptitude
, .ssh/
和.bash_rc
。 Is there a simple rule to cover this without specifically adding each entry? 是否有一个简单的规则来覆盖这个而不是专门添加每个条目?
Just add a pattern to .gitignore
只需在
.gitignore
添加一个模式即可
.*
!/.gitignore
Edit: Added the .gitignore
file itself (matters if it is not yet commited). 编辑:添加
.gitignore
文件本身(如果尚未提交则很重要)。
.gitignore will only effect files that haven't been 'added' already. .gitignore只会影响尚未“添加”的文件。
To make new .gitignore entries affect all files 要使新的.gitignore条目影响所有文件
git commit -a -m "Pre .gitignore changes"
git rm -r --cached .
git add .
git commit -a -m "Post .gitignore changes"
git status
should output "nothing to commit (working directory clean)" ` git status
应输出“nothing to commit(working directory clean)”` In .git/info/exclude
, add this line: 在
.git/info/exclude
,添加以下行:
.*
This will make ignoring all hidden/dot files recursively the default for every repository on the machine. 这将使所有隐藏/点文件递归地忽略机器上每个存储库的默认值。 A separate
.gitignore
file for every repo is not needed this way. 这种方式不需要为每个repo单独的
.gitignore
文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.