【问题标题】:Git push shows git commentsgit push 显示 git 评论
【发布时间】:2018-06-21 12:50:54
【问题描述】:

我在远程 git 存储库中有一个项目,当我推送代码时,它在远程存储库中显示如下:

<<<<<<< HEAD
<?php
/**
 * Front to the WordPress application. This file doesn't do anything, but loads
 * wp-blog-header.php which does and tells WordPress to load the theme.
 *
 * @package WordPress
 */

/**
 * Tells WordPress to load the WordPress theme and output it.
 *
 * @var bool
 */
define('WP_USE_THEMES', true);

/** Loads the WordPress Environment and Template */
require( dirname( __FILE__ ) . '/wp-blog-header.php' );
=======
<?php

/**

 * Front to the WordPress application. This file doesn't do anything, but loads

 * wp-blog-header.php which does and tells WordPress to load the theme.

 *

 * @package WordPress

 */



/**

 * Tells WordPress to load the WordPress theme and output it.

 *

 * @var bool

 */

define('WP_USE_THEMES', true);



/** Loads the WordPress Environment and Template */

require( dirname( __FILE__ ) . '/wp-blog-header.php' );

>>>>>>> dev-wip

如你所见,有一些 git cmets(?我不知道正确的术语,对不起。)可以在代码中看到,例如:

&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD

&gt;&gt;&gt;&gt;&gt;&gt;&gt; dev-wip

谁能帮我解释为什么它不能正确渲染?

【问题讨论】:

  • 好像有冲突。
  • 这是一个合并冲突,'>>>>>> dev-wip' 来自分支 dev-wip。
  • Git conflict markers的可能重复
  • @scharette 有,但我解决了它们并且分支成功合并。
  • @JanakaDombawela 你解决了它们然后推送?

标签: git git-remote


【解决方案1】:

出现此问题是因为文件在您推送代码之前和您最后一次提取或克隆之后的时间段内被修改。

&lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD, ======= and &gt;&gt;&gt;&gt;&gt;&gt;&gt; dev-wip 构成了 git 已经看到的一组冲突。这些标记表明======= 上面的代码与其下面的代码有冲突。

要解决此问题,您应该决定需要保留哪些代码行。 为此,请分析代码并查看哪些更改是相关的并且应该在最终合并中出现。 之后决定删除这些标记 &lt;&lt;&lt;&lt;&lt;&lt;&lt; HEAD, ======= and &gt;&gt;&gt;&gt;&gt;&gt;&gt; 并确保您的代码是正确的。

避免这种情况的步骤是:

  1. 在合并之前检查您的代码,最好在创建拉取请求 (PR) 之前检查您的代码
  2. 在推送到分支之前尝试使用git pull -r origin &lt;branch_name&gt;

【讨论】:

    猜你喜欢
    • 2011-11-09
    • 2011-05-29
    • 2011-05-23
    • 2019-06-06
    • 1970-01-01
    • 2021-10-15
    • 2019-03-02
    • 2015-12-25
    • 1970-01-01
    相关资源
    最近更新 更多