3

我有一条规则可以忽略secret.py(在我的情况下是production.py),一旦我添加了.gcloudignore,github就停止遵循该规则......在gitignore和gcloudignore之间是否存在某种我不知道的规则覆盖?

my-project/
    .git
    .gitignore
    my-project/
        .gcloudignore
        settings/
            base.py
            local.py
            production.py

我的.gitignore:

my-project/my-project/settings/production.py
my-project/my-project/settings/local.py

我的 .gcloudignore:

# This file specifies files that are *not* uploaded to Google Cloud Platform
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
#   $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore

*.sqlite3
settings/local.py

最终结果是“local.py”没有被推送到谷歌云或 github。但是,“production.py”被推送到 github 和 gcloud。

4

2 回答 2

1

如果您之前(可能是不小心)向 git 提交了包含 的更改my-project/my-project/settings/production.py,那么即使随后将其添加到.gitignore.

假设您位于项目的根目录,您可以使用

$ git log my-project/my-project/settings/production.py

查看它的 git 历史。如果它存在于您的回购中,您可以这样做

$ git rm --cached my-project/my-project/settings/production.py

其从 repo中删除,但将其保留在本地(工作)环境中。

于 2020-05-13T16:24:40.077 回答
0

看起来您正在强制忽略之前应用的规则。

虽然确保通过以下方式启用 cloudignore

gcloud config set gcloudignore/enabled true

并确保将 .gcloudignore -> 放在项目的根目录中/基本上是 .git .gitignore 所在的位置。

于 2020-05-12T20:54:41.677 回答