【发布时间】:2021-04-21 20:33:06
【问题描述】:
我的 Django 项目中有以下结构
gitignore 是https://www.toptal.com/developers/gitignore/api/django建议的那个
初始化GIT的步骤是:用apps/A和apps/B创建项目,创建.gitignore文件并运行git init。
然后我跑了makemigrations和migrate
当从 master 开始,使用 apps/ZApp 创建一个名为 Z 的新分支,创建一个新模型并从该分支执行 makemigrations 和 migrate 时,就会出现问题。因此:
$ git checkout -b Z
$ cd apps
$ django-admin startapp Z
$ cd ..
然后我申请makemigrations 和migrate 并返回master...当我在master 中时,我看到那些应该被忽略的文件,我找不到原因...他们应该'不在那里......所有文件都应该在各自的分支中
我不明白......谁来帮助我
更新:我的 gitignore
### Personal ###
secret.json
### Django ###
*.log
*.pot
*.pyc
__pycache__/
local_settings.py
db.sqlite3
db.sqlite3-journal
media
# If your build process includes running collectstatic, then you probably don't need or want to include staticfiles/
# in your Git repository. Update and uncomment the following line accordingly.
# <django-project-name>/staticfiles/
### Django.Python Stack ###
# Byte-compiled / optimized / DLL files
*.py[cod]
*$py.class
# C extensions
*.so
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
pytestdebug.log
# Translations
*.mo
# Django stuff:
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
doc/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# poetry
#poetry.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
# .env
.env/
.venv/
env/
venv/
ENV/
env.bak/
venv.bak/
pythonenv*
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# pytype static type analyzer
.pytype/
# operating system-related files
# file properties cache/storage on macOS
*.DS_Store
# thumbnail cache on Windows
Thumbs.db
# profiling data
.prof
【问题讨论】:
-
应该从 Git 中忽略这些文件。如果您正在查看文件资源管理器,您应该仍然可以看到这些文件,因为它们确实存在。您只是不应该在创建提交的待处理更改列表中看到它们。
-
我已经忽略了来自 git 的文件...我将使用 gitignore 的内容进行更新
-
对不起,我不是说您的 .gitignore 错误...看起来不错。我的意思是您显示的视图似乎是文件资源管理器,并且文件应该出现在那里(我假设)。但是看看你的 Changes 视图,看看你将要提交什么,你不应该在那里看到它们。
-
它们不应该被看到,因为我在我的分支中的更改保留在我的分支中......当我返回 master 时,我不应该看到我在分支中所做的任何事情......或者我认为是这样远。
-
啊!现在这些文件被 Git 忽略了,它们没有被跟踪,所以当你切换分支时它们不会被删除。解决一个问题,创造另一个。 ;)
标签: django git visual-studio-code