简体   繁体   English

在本地分支上进行Git更改,检出了master,而master现在已损坏

[英]Git- made changes on a local branch, checked out master, and master is now broken

I am working on a Python/ Django project, using Git to manage my version control. 我正在使用Git管理我的版本控制的Python / Django项目。

I recently made some changes on a branch called conceptCalendar3 , and the changes I made broke my site. 最近,我在名为conceptCalendar3的分支上进行了一些更改,所做的更改破坏了我的网站。

I committed the changes to that branch, and then checked out master , which, I had branched from in order to create the conceptCalendar3 branch. 我将更改提交到该分支,然后签出master ,我从该分支开始创建了conceptCalendar3分支。 However, when I now to try to view my site from the localhost , on master branch (on which I have not made any changes since it was last working), I now get a message in the browser telling me that: 但是,当我现在尝试从localhost master分支上查看我的网站时(自上次运行以来,我尚未对其进行任何更改),我现在在浏览器中收到一条消息,告诉我:

This site can't be reached 无法访问该网站

localhost refused to connect 本地主机拒绝连接

The Python console is displaying a lot of output with error messages that I've not seen before: Python控制台显示了很多输出,其中包含我从未见过的错误消息:

File "/Users/.../Documents/Dev/moonhub/moon/moon/urls.py", line 27, in url(r'^costing/', include('costing.urls', namespace="costing")), File "/Users/.../.virtualenvs/moon/lib/python2.7/site-packages/django/conf/urls/ init .py", line 52, in include urlconf_module = import_module(urlconf_module) File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/ init .py", line 37, in import_module import (name) File "/Users/.../Documents/Dev/moonhub/moon/costing/urls.py", line 2, in from . 文件“ /Users/.../Documents/Dev/moonhub/moon/moon/urls.py”,第27行,位于url(r'^ costing /',include('costing.urls',namespace =“ costing” )),文件“ /Users/.../.virtualenvs/moon/lib/python2.7/site-packages/django/conf/urls/ init .py”,第52行,包含在urlconf_module = import_module(urlconf_module)文件中“ /System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/importlib/ init .py”,第37行,在import_module 导入 (名称)文件“ /Users/.../Documents/Dev中/moonhub/moon/costing/urls.py”,第2行,来自。 import views File "/Users/.../Documents/Dev/moonhub/moon/costing/views.py", line 2900, in from projects.views import get_project_folder File "/Users/elgan/Documents/Dev/moonhub/moon/projects/views.py", line 38, in from .forms import * File "/Users/.../Documents/Dev/moonhub/moon/projects/forms.py", line 1207, in class PostDepMeetingForm(ValidatedForm): File "/Users/.../.virtualenvs/moon/lib/python2.7/site-packages/django/forms/models.py", line 257, in new raise FieldError(message) django.core.exceptions.FieldError: Unknown field(s) (meeting_date_time) specified for Survey 从projects.views中,导入视图文件“ /Users/.../Documents/Dev/moonhub/moon/costing/views.py”,行2900导入get_project_folder文件“ / Users / elgan / Documents / Dev / moonhub / moon /projects/views.py”,第38行,来自.forms import *文件“ /Users/.../Documents/Dev/moonhub/moon/projects/forms.py”,行1207,在类PostDepMeetingForm(ValidatedForm)中:文件“ /Users/.../.virtualenvs/moon/lib/python2.7/site-packages/django/forms/models.py”的第257行在新的 FieldError(message)django.core.exceptions中。 FieldError:为调查指定了未知字段(会议日期时间)

The 'field' that it seems to be complaining about, meeting_date_time is one that I added on the conceptCalendar3 branch- but it doesn't exist in the code on the master branch... 似乎在抱怨的“字段”, meeting_date_time是我在conceptCalendar3分支上添加的,但是在master分支的代码中不存在...

I have tried running git pull origin master to ensure that I have the latest version of code from the live version of the project, but this tells me that everything is up-to-date. 我已经尝试运行git pull origin master来确保我拥有项目实时版本中的最新代码,但这告诉我所有内容都是最新的。

So why can't I view a version of my site locally, and why am I getting these errors in the console? 那么,为什么我不能在本地查看网站的版本,为什么在控制台中出现这些错误?

Edit 编辑

I tried checking out an old commit, and at one point was in a detached head state- could it be that I am still in this detached head state, and so some of my code is point to master , but some of it is pointing to conceptCalendar ? 我想检查我的一个老犯,并在一个点是在一个detached head国有那也许是因为我仍然在这个detached head状态,所以我的一些代码点master ,但它的一些指向conceptCalendar If that's the case, how would I check, and how would I resolve it? 如果是这样,我将如何检查以及如何解决?

Possible causes: 可能的原因:

  1. (Git) You forgot to git add files in the conceptCalendar branch, and they are still lying around when you checkout master . (Git)您忘记了在conceptCalendar分支中git add文件,当您checkout master时它们仍然在附近。

  2. (Python) You have stale .pyc files in your project. (Python)您的项目中有陈旧的.pyc文件。 Remove them. 删除它们。

  3. (Django) You forgot to makemigrations in the conceptCalendar branch (Django的),你忘了makemigrationsconceptCalendar分支

  4. (Django) You ran migrate on the conceptCalendar branch, your database schema has changed, but now the code on master reflects the old schema. (Django)您在conceptCalendar分支上进行了migrate ,数据库模式已更改,但是现在master上的代码反映了旧模式。 Rebuild your database, or migrate backwards. 重建数据库,或向后迁移。

I'm betting my money on this last point. 我把钱押在最后一点上。 From the error you posted, i'm thinking that maybe a Form is extending ModelForm for a Model that changed in the other branch. 从您发布的错误中,我在想,一个Form可能正在为另一个分支中更改的Model扩展ModelForm Check that all fields exist in the underlying model, and in the database. 检查所有字段都存在于基础模型和数据库中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM