git merge-如果合并一个旧分支,旧问题会合并到master中吗? [英] Git merge- will old problems be merged into master if I merge an old branch?

查看:128
本文介绍了git merge-如果合并一个旧分支,旧问题会合并到master中吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Git用作开发的版本控制,并且相对较新.

在开始该项目的工作后不久,我创建了一个名为 updateCards 的分支,以解决项目中的特定错误.

但是,在进行此操作时,以及在我将更改推送到服务器之前,提出了其他一些错误,需要更紧急地注意.结果,我将更改提交到 updateCards 上,然后针对其他每个更紧迫的bug切换到新的分支.

我已经解决了其他错误,将我为它们创建的分支合并到 master 中,并将对它们的更改推送到服务器中.

我现在想回到旧的 updateCards 分支,将其与master&推送到服务器.当我从 updateCards 分支查看项目时,我看到该分支创建的错误已解决,因此很高兴可以将其推送到服务器./p>

但是,我不确定的是,如果我合并了,自创建 updateCards 以来,我对服务器上的 master 进行了其他一些更改,现在将updateCards 更改为 master ,我将合并 updateCards 中已存在但已在 master 中解决的所有旧错误吗到 master ,因为已在master上修复了这些错误的文件将与 updateCards 上的相同文件不同?还是Git会发现这些文件在 master 上的更改比在 updateCards 上的更改更新,所以不合并这些更改?

我运行了 git diff master..updateCards ,它显示了有关两个分支之间差异的输出:

  diff --git a/buying/templates/buying/update_card_numbers.html b/buying/templates/buying/update_card_numbers.html索引6cc5938..5f6a8f3 100644--- a/buying/templates/buying/update_card_numbers.html+++ b/buying/templates/buying/update_card_numbers.html@@ -25,8 +25,8 @@< table class ="left">< thead>< tr>-第卡持卡人(/th)< th卡号</th>+&th;持卡人</th></tr></thead>diff --git a/buying/views.py b/buying/views.py索引08d2fd6..c777020 100644--- a/buying/views.py+++ b/buying/views.py@@ -1555,6 +1555,8 @@ def update_card_numbers(request):持卡人=数据['id']cardholder.card_no =数据['card_no']cardholder.save()+#cardholder.card_no.save()+ #data ['travis_card_no'].save()打印持卡人,持卡人.card_noHttpResponseRedirect(reverse('buying:update_card_numbers'))diff --git a/costing/templates/pdf2_base.html b/costing/templates/pdf2_base.html索引3826a98..c139068 100644--- a/costing/templates/pdf2_base.html+++ b/costing/templates/pdf2_base.html@@ -83,8 +83,6 @@< td>< span class ="project-name"> {{project.project_name | upper}}</span></td>-<!-ERF(2016/12/07 @ 1615)在标题中显示今天的日期->-< td>{%date_to_display%}</td></tr></table></div>差异--git a/costing/views.py b/costing/views.py索引902f9ff..f8a3f77 100644--- a/costing/views.py+++ b/costing/views.py@@ -2438,9 +2438,6 @@ def pdf2_master(request,project_id):"保存到当前预算(无版本号),因为一旦收到存款,就不再使用版本.""预算= get_current_budget(project_id)-#ERF(07/12/2016 @ 1615)创建日期变量,以在生成PDF时显示今天的日期-date_to_display = datetime.now()--如果没有预算:Budget.objects.create(project = project,current_marker = 1) 

但是我不确定如何解释此输出...这些行是否以-开头,存在于 updateCards 中,但在 master中不存在,而以 + 开头的行在 master 中存在,但在 updateCards 中不存在,反之亦然?

如果我运行 merge ,哪些更改会朝哪个方向复制?

解决方案

根据您的git diff输出,可以将updateCards合并到master分支中.由两个分支比较的文件(对于updateCards为 +,对于主版本为–code ):

updateCards分支更新的文件

update_card_numbers.html

views.py 添加update_card_numbers(请求)函数

master分支更新的文件

pdf2_base.html
views.py 添加一些新行

实际上,他们修改了不同的地方.您可以合并两个分支,而对updatedCards分支和已合并到master的新分支上的固定错误没有影响.

您可以在真正合并之前执行 git merge updateCards --no-commit .它将显示哪些文件有冲突,然后您可以使用 git merge --abort 停止.当您运行 git merge updateCards 时,会有冲突文件,只是保存您要保留的内容,然后对每个冲突文件和 git使用 git add filename 提交.

I am using Git as the version control for my development, and am relatively new to it.

Shortly after starting work on this project, I created a branch called updateCards to work on resolving a particular bug within the project.

However, while working on this, and before I had pushed my changes to the server, several other bugs were raised that required more urgent attention. As a result, I committed my changes to updateCards, and then switched to a new branch for each of these other more pressing bugs.

I have resolved these other bugs, merged the branches I created for them into master and pushed my changes to the server for each of them.

I now want to go back to the old updateCards branch, merge that with master & push to the server. When I view the project from the updateCards branch, I can see that the bug that this branch was created for has been resolved, so I'm happy that I am ready to push it to the server.

However, what I'm unsure about is, given that I have made several other changes to master on the server since creating updateCards, if I merge updateCards to master now, will I merge any of the old bugs that were existing in updateCards but are now resolved in master back to master, since the files where these bugs have been fixed on master will be different to those same files on updateCards? Or will Git see that the changes on master for these files are more recent than the changes on updateCards, and so not merge those changes?

I ran a git diff master..updateCards, and this has displayed output about the differences between the two branches:

diff --git a/buying/templates/buying/update_card_numbers.html b/buying/templates/buying/update_card_numbers.html
index 6cc5938..5f6a8f3 100644
--- a/buying/templates/buying/update_card_numbers.html
+++ b/buying/templates/buying/update_card_numbers.html
@@ -25,8 +25,8 @@
            <table class="left">
                    <thead>
                            <tr>
-                                       <th>Cardholder</th>
                                    <th>card no</th>
+                                       <th>Cardholder</th>
                            </tr>
                    </thead>

diff --git a/buying/views.py b/buying/views.py
index 08d2fd6..c777020 100644
--- a/buying/views.py
+++ b/buying/views.py
@@ -1555,6 +1555,8 @@ def update_card_numbers(request):
                                            cardholder = data['id']
                                            cardholder.card_no = data['card_no']
                                            cardholder.save()
+                                               #cardholder.card_no.save()
+                                               #data['travis_card_no'].save()
                                            print cardholder, cardholder.card_no

                            HttpResponseRedirect(reverse('buying:update_card_numbers'))
diff --git a/costing/templates/pdf2_base.html b/costing/templates/pdf2_base.html
index 3826a98..c139068 100644
--- a/costing/templates/pdf2_base.html
+++ b/costing/templates/pdf2_base.html
@@ -83,8 +83,6 @@
                                            <td>
                                                    <span class="project-name">{{project.project_name|upper}}</span>
                                            </td>
-                                               <!--ERF(07/12/2016 @ 1615) Display today's date in the header -->
-                                               <td> {% date_to_display %}</td>
                                    </tr>
                            </table>
                    </div>  
diff --git a/costing/views.py b/costing/views.py
index 902f9ff..f8a3f77 100644
--- a/costing/views.py
+++ b/costing/views.py
@@ -2438,9 +2438,6 @@ def pdf2_master(request, project_id):
            """ Save to the current budget (no version number), as versions not used once deposit is received """
            budget = get_current_budget(project_id)

-               #ERF(07/12/2016 @ 1615) Create a date variable to displays today's date on the PDF when it's generated
-               date_to_display = datetime.now()
-
            if not budget:
                    Budget.objects.create(project=project, current_marker=1)

But I'm not sure how to interpret this output... Are the lines beginning with - something that exists in updateCards, but not in master, and the lines beginning with + something that exists in master, but not in updateCards, or vice versa?

Which changes will be copied in which direction if I run a merge?

解决方案

Based on your git diff output, it’s ok to merge updateCards in master branch. Files compared by the two branchs (+ for updateCards and – for master) as below:

updateCards branch updated files,

update_card_numbers.html

views.py add update_card_numbers(request) function

master branch updated files,

pdf2_base.html
views.py add some new line

So actually, they modified different places. You can merge the two branches with no effect on fixed bugs on updatedCards branch and the new branch you have merged into master.

You can execute git merge updateCards --no-commit before really merge. It will show which files have conflict, the then you can use git merge --abort to stop. When you run git merge updateCards, there will have conflict files, just save what you want to keep, and then use git add filename for each conflict files and git commit.

这篇关于git merge-如果合并一个旧分支,旧问题会合并到master中吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆