git - 试图排除某些文件但想添加其他所有文件
git - trying to exclude certain files but want to add everything else
我想将整个网站添加到存储库,但我希望它忽略几个文件。
所以在我克隆的文件夹中,我转到了排除文件并添加了位于站点根目录中的文件名。
例如
/myrootfile.php
然后我尝试 git add *
添加所有内容,但是我收到以下警告...
The following paths are ignored by one of your .gitignore files:
myrootfile.php
Use -f if you really want to add them.
fatal: no files added
我想知道我应该如何添加其他所有内容而忽略此文件?
谢谢
git add .
有效,我不确定为什么,但这解决了问题,之后 git add *
似乎有效,所以我假设它添加了所需的 .gitignore 文件。
shell 正在扩展你的 glob 模式,所以当你 运行
git add *
就好像你调用了
git add myrootfile.php this.php that.php the-other.html
因此可怜的 git 很困惑,因为你说你想忽略它,但后来又明确地添加了它。
在您的网站根目录中,运行以下内容
git add .
点指的是当前目录,git然后递归下降到该目录。
我想将整个网站添加到存储库,但我希望它忽略几个文件。
所以在我克隆的文件夹中,我转到了排除文件并添加了位于站点根目录中的文件名。
例如
/myrootfile.php
然后我尝试 git add *
添加所有内容,但是我收到以下警告...
The following paths are ignored by one of your .gitignore files:
myrootfile.php
Use -f if you really want to add them.
fatal: no files added
我想知道我应该如何添加其他所有内容而忽略此文件?
谢谢
git add .
有效,我不确定为什么,但这解决了问题,之后 git add *
似乎有效,所以我假设它添加了所需的 .gitignore 文件。
shell 正在扩展你的 glob 模式,所以当你 运行
git add *
就好像你调用了
git add myrootfile.php this.php that.php the-other.html
因此可怜的 git 很困惑,因为你说你想忽略它,但后来又明确地添加了它。
在您的网站根目录中,运行以下内容
git add .
点指的是当前目录,git然后递归下降到该目录。