git ignore在使用GCloud的gcloudignore时不忽略文件

2024-07-05 15:19:09 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一个忽略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

my.gcloud忽略:

# 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


Tags: thepygitgithubprojectsettings规则my
2条回答

如果您以前(可能是意外地)提交了对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

remove it from the repo,但将其保存在本地(工作)环境中

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

尽管如此,请确保cloudignore是通过启用的

gcloud config set gcloudignore/enabled true

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

相关问题 更多 >