I'd like to have Git ignore all hidden files and directories, i.e. .aptitude
, .ssh/
and .bash_rc
. Is there a simple rule to cover this without specifically adding each entry?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Just add a pattern to .gitignore
.*
!/.gitignore
Edit: Added the .gitignore
file itself (matters if it is not yet commited).
回答2:
.gitignore will only effect files that haven't been 'added' already.
To make new .gitignore entries affect all files
- Make changes to .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)" `
回答3:
In .git/info/exclude
, add this line:
.*
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.