首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >为什么git要删除合并时添加在一个分支上的行?

为什么git要删除合并时添加在一个分支上的行?
EN

Stack Overflow用户
提问于 2013-12-03 06:00:06
回答 2查看 191关注 0票数 2

我正在使用git来跟踪我的一个小型网站的开发。我现在有两个分支:

  1. 一个master分支,它的代码(据说)已经准备好部署了
  2. 一个dev分支,在那里我尝试了一些东西,直到我认为它们已经准备好部署

为了习惯于在将开发提升到更多人的情况下,我通常在签出master分支并将dev合并到它之前,将master分支与dev分支合并,- so可以解决dev分支中的任何冲突,而不是master上的冲突。

上一次我这么做的时候,一些代码就消失了( id="all_text"的css代码,参见下面的代码)。我认为这是因为master分支中没有代码,而且我正在将master代码移动到dev分支中(但这不是我记得它的行为方式),所以我取消了合并(git reset --merge;我在GIT1.7.0.3上),检查了master分支并将其与dev分支合并。同样的结果,- most的代码在#all_text中消失了。

我不知道为什么会发生这种事。最近的更改在dev分支上,因此它们应该在合并中合理地结转,而不是被删除。

有什么方法可以解决这个问题,而不需要手工将dev中的文档内容复制到master中这种丑陋的黑客行为?

发展内容(index.css)

代码语言:javascript
运行
复制
body {
    margin:0;
    padding:0;
}

/* attributes for the <div> that encapsules the h1 and the encouragement */

#all_text {
    position: relative;
    height: 50%;
    width: 70%;
    margin-top:8em;
    margin-left:auto;
    margin-right:auto;
    text-align: center;

//  background-color: yellow; // Trace code to better see the design
}

h1 {
    position: relative;
    text-align: center;

    font-size: 700%;
    color: #4970A8;
/*  color: #5AA0FF; */
    text-shadow: 4px 4px 8px gray;

//  background-color: green; // Trace code to better see the design
}

div.encouragement {
    position: relative;
    width: 70%;
    bottom: 25px;

    color: #4970A8;
    font-size: 170%;

//  background-color: red; // Trace code to better see the design
}

主内容(index.css)

代码语言:javascript
运行
复制
#all_text {
    position: relative;
}

h1 {
    color: #4970A8;
/*  color: #5AA0FF; */
    text-align: center;
/*  text-vertica-align: center; */
    font-size: 700%;
    position: relative;
    top:30%;

    text-shadow: 4px 4px 8px gray;
}

div.encouragement {
    color: #4970A8;
    text-align: center;
    font-size: 150%;
/*  position: absolute;
    top: 5%m;
    left:7%em; */
/*  text-shadow: 2px 2px 8px gray; */
}

合并内容(index.css)

代码语言:javascript
运行
复制
#all_text {
    position: relative;
}

h1 {
<<<<<<< HEAD
    position: relative;
    text-align: center;

    font-size: 700%;
    color: #4970A8;
/*  color: #5AA0FF; */
    text-shadow: 4px 4px 8px gray;

//  background-color: green; // Trace code to better see the design
}

div.encouragement {
    position: relative;
    width: 70%;
    bottom: 25px;

    color: #4970A8;
    font-size: 170%;

//  background-color: red; // Trace code to better see the design
=======
    color: #4970A8;
/*  color: #5AA0FF; */
    text-align: center;
/*  text-vertica-align: center; */
    font-size: 700%;
    position: relative;
    top:30%;

    text-shadow: 4px 4px 8px gray;
}

div.encouragement {
    color: #4970A8;
    text-align: center;
    font-size: 150%;
/*  position: absolute;
    top: 5%m;
    left:7%em; */
/*  text-shadow: 2px 2px 8px gray; */
>>>>>>> master
}

#all_text{…}部分的大部分文本发生了什么变化?

事先谢谢你。

更新:添加了合并库(根据dyng’s说明)。

运行git show $(git merge-base dev master)会给我这样的结果:

代码语言:javascript
运行
复制
diff --git a/www/index.css b/www/index.css
index b837a87..d8c48ef 100644
--- a/www/index.css
+++ b/www/index.css
@@ -1,25 +1,44 @@
+body {
+       margin:0;
+       padding:0;
+}
+
+/* attributes for the <div> that encapsules the h1 and the encouragement */
 #all_text {
        position: relative;
+       height: 50%;
+       width: 70%;
+       margin-top:8em;
+       margin-left:auto;
+       margin-right:auto;
+       text-align: center;
+               
+//     background-color: yellow; // Trace code to better see the design
 }

+
 h1 {
        color: #4970A8;
 /*     color: #5AA0FF; */
        text-align: center;
-/*     text-vertica-align: center; */
+       display: inline-block;
        font-size: 700%;
        position: relative;
-       top:30%;
+       left:0.5em;
+

        text-shadow: 4px 4px 8px gray;
+               
+//     background-color: green; // Trace code to better see the design
 }

-div.encouragement {
+span.encouragement {
        color: #4970A8;
-       text-align: center;
-       font-size: 150%;
-/*     position: absolute;
-       top: 5%m;
-       left:7%em; */
-/*     text-shadow: 2px 2px 8px gray; */
+       font-size: 170%;
+       position: relative;
+       top: 3em;
+       right:18em; 
+
+
+//     background-color: red; // Trace code to better see the design
 }
\ No newline at end of file
EN

Stack Overflow用户

发布于 2013-12-03 08:53:58

通常,在签出主分支并将dev合并到主分支之前,我通常会将主分支与dev分支合并。

为了避免这些合并问题,最好是:

  • 在主服务器上重新设置开发
  • 在将dev合并到master之前

这样,您就可以在主服务器上重新应用(重基)您的更改,从而使您的dev代码“消失”的可能性不大。

票数 1
EN
查看全部 2 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20343970

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档