【问题标题】:Git- link on local master branch works, doesn't work on live version本地主分支上的 Git-link 有效,不适用于实时版本
【发布时间】:2017-01-09 11:40:11
【问题描述】:

我正在开发一个 Python/Django 项目,使用 Git 来管理版本控制。

我目前在本地机器上的 master 分支和服务器上的实时 master 分支之间存在一些不一致的问题...

我之前在本地计算机上修复了一个错误,并将更改推送到服务器,但是,服务器上实时版本的其中一个页面上的链接现在不再有效,即使它在我的本地版本...

链接位于:www.mysite.co.uk/costing/id/ - 当我点击“报告”链接时,我收到一个错误页面,上面写着:

/costing/6108/payment-report/overview/ 处的模板语法错误

第 87 行的块标记无效:“date_to_display”,预期为“elif”、“else”或“endif”。您是否忘记注册或加载此标签?

但是在我的本地机器上,在master 分支上,这个链接可以正常工作。

查看了现场版本抱怨invalid block tag的模板,我可以看到它在块中:

{% block content_payment_schedule %}
    {% if not webview %}
        <div>
            <table>
                <tr>
                    ...
                </tr>
                <tr>
                    <td>
                        <span class="project-name">{{project.project_name|upper}}</span>
                    </td>
                    <!-- Display today's date in the header -->
                    <td> {{ date_to_display }}</td>
                </tr>
            </table>
        </div>  
    {% endif %}
    ...
{% endblock content_payment_schedule %}

这是我之前添加到代码中的内容(在通过单击链接生成的 PDF 的标题中显示日期),并且一直工作到现在...

当我浏览到:localhost:8000/costing/id/ 并单击相同的“报告”链接时,我会进入报告页面:localhost:8000/costing/id/payment-report/overview/(它显示了一个“选项卡式内容”区域,其中包含各种报告的选项卡,并自动选择了“概述”选项卡)。

从本地机器,在master 分支上,如果我尝试运行

git commit -m 'message about commit',然后

git push origin master

Git 显示一条消息告诉我:

一切都是最新的

git status 显示一条消息:

在主分支上

没有提交,工作目录干净

那么,当我的本地版本正常工作并且服务器上的版本与我的本地版本是最新的时,为什么我会在实时版本上得到这个 TemplateSyntaxError

【问题讨论】:

  • 你检查过,是否使用相同的设置文件。有区别吗?您确定包含您的标签date_to_display 的文件在服务器上吗?
  • 如果代码的实时版本使用{{ date_to_display }},那么看起来您已经拉取了最新版本的代码。在那种情况下,我认为问题在于您还没有重新启动服务器。
  • 我已经多次重新启动服务器 - 这个变量是几周前添加的,从那时起我已经修复了一些错误 - 每次我将更改推送到服务器时都会重新启动服务器......
  • 你只有fixed the bug on Friday。要么在线服务器仍然有{% date_to_display %},在这种情况下你必须拉取最新版本的代码,或者在线服务器有{{ date_to_display }},在这种情况下你必须重新启动服务器。您显示的代码{{ date_to_display }} 不会导致错误Invalid block tag

标签: django git github version-control


【解决方案1】:

现在对于您的本地仓库,git status 说:

On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working tree clean

然后你可以通过git fetch origin从远程repo中获取,并使用git status显示本地master分支。如果它说,

On branch master
Your branch is behind 'origin/master' by 1 commit, and can be fast-forwarded.
  (use "git pull" to update your local branch)
nothing to commit, working tree clean

这意味着,您的本地主分支不是最新版本。如果您希望实时版本(远程 master 分支)与本地 master 分支保持一致,您可以使用git push -f origin master

【讨论】:

    猜你喜欢
    • 2013-03-02
    • 2017-12-15
    • 1970-01-01
    • 2021-08-18
    • 1970-01-01
    • 1970-01-01
    • 2017-11-26
    • 2023-03-19
    • 1970-01-01
    相关资源
    最近更新 更多