gpt4 book ai didi

git - 从 pythonanywhere 添加/提交时,将 `__pycache__` 保留在我的存储库之外

转载 作者:行者123 更新时间:2023-12-04 04:24:42 25 4
gpt4 key购买 nike

我在本地 win7 机器上构建了一个 Web 应用程序。我用 pycharm 做到了,并使用 git 作为版本控制。我是一个完全的 git 新手。

我将存储库放在 github 上,以便我可以将 web 应用程序暂存到我的 pythonanywhere 服务器。

在 pythonanywhere 方面,我对各种文件进行了一些小的编辑。我想将这些更改提交回存储库。

(udemy) 10:44 ~/keystone (master)$ git commit -m "got it running on pythonanywhere staging"
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
modified: keystone/settings/base.py
modified: keystone/settings/local_postgres.py
modified: keystone/settings/staging_straits.py
deleted: p0150_1.pdf
Untracked files:
crapboard/__pycache__/
crapboard/migrations/__pycache__/
crapboard/templatetags/__pycache__/
keystone/__pycache__/
keystone/settings/__pycache__/
no changes added to commit

我想将三个修改的文件和一个删除提交到存储库。

所以我做了
(udemy) 14:03 ~/keystone (master)$ git add --all
(udemy) 14:03 ~/keystone (master)$ git commit -m "staged to pythonanywhere"
[master ac6bb7e] staged to pythonanywhere
27 files changed, 23 insertions(+), 115 deletions(-)
create mode 100644 crapboard/__pycache__/__init__.cpython-36.pyc
create mode 100644 crapboard/__pycache__/admin.cpython-36.pyc
create mode 100644 crapboard/__pycache__/apps.cpython-36.pyc
create mode 100644 crapboard/__pycache__/forms.cpython-36.pyc
create mode 100644 crapboard/__pycache__/models.cpython-36.pyc
create mode 100644 crapboard/__pycache__/pdf_views.cpython-36.pyc
create mode 100644 crapboard/__pycache__/urls.cpython-36.pyc
create mode 100644 crapboard/__pycache__/views.cpython-36.pyc
create mode 100644 crapboard/migrations/__pycache__/0001_initial.cpython-36.pyc
create mode 100644 crapboard/migrations/__pycache__/0001_squashed_0005_auto_20170921_2154.cpython-36.pyc
create mode 100644 crapboard/migrations/__pycache__/0002_auto_20170909_1137.cpython-36.pyc
create mode 100644 crapboard/migrations/__pycache__/0003_auto_20170912_2029.cpython-36.pyc
create mode 100644 crapboard/migrations/__pycache__/0004_problem_author.cpython-36.pyc
create mode 100644 crapboard/migrations/__pycache__/0005_auto_20170921_2154.cpython-36.pyc
create mode 100644 crapboard/migrations/__pycache__/__init__.cpython-36.pyc
create mode 100644 crapboard/templatetags/__pycache__/__init__.cpython-36.pyc
create mode 100644 crapboard/templatetags/__pycache__/crapboard_filters.cpython-36.pyc
create mode 100644 keystone/__pycache__/__init__.cpython-36.pyc
create mode 100644 keystone/__pycache__/urls.cpython-36.pyc
create mode 100644 keystone/settings/__pycache__/__init__.cpython-36.pyc
create mode 100644 keystone/settings/__pycache__/base.cpython-36.pyc
create mode 100644 keystone/settings/__pycache__/settings_secret.cpython-36.pyc
create mode 100644 keystone/settings/__pycache__/staging_straits.cpython-36.pyc
rewrite keystone/settings/staging_straits.py (65%)
delete mode 100644 p0150_1.pdf

啊。它 promise 了所有这些 __pycache__目录也是。

我猜这是因为我应该在我的 pythonanywhere 服务器上制作某种全局/通用 .gitignore 文件?

所以问题:

1) 我如何摆脱这个 pycache 永久从我的存储库中获取的东西
2)我如何防止我的pythonanywhere服务器将来尝试将这些东西添加到我的存储库中——我在pycharm/本地机器上没有这个问题——它忽略了这些文件。

最佳答案

根据 git docs ,很简单地将以下内容添加到 ~/.gitignore 中:

**/__pycache__

A leading "**" followed by a slash means match in all directories. For example, "**/foo" matches file or directory "foo" anywhere, the same as pattern "foo". "**/foo/bar" matches file or directory "bar" anywhere that is directly under directory "foo".

关于git - 从 pythonanywhere 添加/提交时,将 `__pycache__` 保留在我的存储库之外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46428889/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com