我有一个包含 .gitignore
文件的 Git 存储库,其中列出了一些要忽略的文件(在构建过程中创建)。
$ cat .gitignore
foo
$ ls
bar
$ git status
On branch master
nothing to commit, working directory clean
$ touch foo
$ ls
bar foo
$ git status
On branch master
nothing to commit, working directory clean
$
在该存储库的特定克隆中,我确实想要查看 .gitignore
中列出的文件。
这可以通过 --ignored
选项到 git status
来完成:
$ git status
On branch master
nothing to commit, working directory clean
$ git status --ignored
On branch master
Ignored files:
(use "git add -f <file>..." to include in what will be committed)
foo
nothing to commit, working directory clean
$
不错。我的问题是:我怎样才能使这个对于 given 存储库永久存在,这样我就不必记得添加 --ignored
标志?
$ git status
On branch master
Ignored files:
(use "git add -f <file>..." to include in what will be committed)
foo
nothing to commit, working directory clean
$
我确定有一些 git 配置
允许我配置我的克隆以忽略 .gitignore
的内容...
此外,我不想为所有 存储库设置此选项;仅供少数人使用。
最佳答案
您需要做的是为 $ git status
命令创建一个别名(我们称之为 istatus
)。
$ git istatus
On branch master
Ignored files:
(use "git add -f <file>..." to include in what will be committed)
foo
nothing to commit, working directory clean
怎么做是described here甚至还有 a similar question on SO .
TL;DR:基本上你只需要在 ~/.gitconfig 中添加几行:
[alias]
istatus = status --ignored
关于git - 如何让 git 忽略 .gitignore 中的忽略,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25909293/