合并不带南瓜和带南瓜选项的提交 [英] Merge commit without squash vs with squash option

查看:127
本文介绍了合并不带南瓜和带南瓜选项的提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在日常工作中,我使用SmartGit作为选择的客户端.但是,我的团队成员坚持使用git本机,非商业GUI.我们发现合并提交的外观有些差异.

On daily routine i use SmartGit as client of choose. My team members however stick to git native, non commercial GUI. We discovered some differences in how our merge commits looks like.

这些是SmartGit在请求合并分支时提供的选项:

Those are options that SmartGit gives when requested to merge branch:

在下面的图形上,您可以看到我的示例SmartGit图形输出,其中包含:

On below graph you can see my example SmartGit graph output, containing:

  • 单个master分支
  • 使用merge commit选项合并到一个分支的主分支
  • 一个分支与simple commit选项合并
  • single master branch
  • One branch merged to master with merge commit option
  • One branch merged with simple commit option

其中一个分支(with_merge_branch)通过通过行将分支与主节点联接来可视化合并操作.第二个(normal_commit_branch)没有.

One of branches (with_merge_branch) is visualizing merge operation by joining branch with master via line. Second one (normal_commit_branch) does not.

问题是,如何在本机git命令中强制执行两种行为? IE.这两个提交有什么区别?

Question is, how to enforce both behaviors in native git commands? I.e. whats the difference between those two commits?

推荐答案

两种合并之间的区别只是提交历史记录中的不同(如您在图中显示的日志所示).

The difference between the two kinds of merge are only different in the commit history (as you showed the logs in graph).

让我们用图表来说明.合并之前,假定提交历史如下:

Let's illustrate by graphs. Assume the commit history as below before merging:

A---B---C---D  master
     \
      E---F---G  develop

合并提交(多个父母):

使用的命令是git merge branchname.这是合并两个分支的默认方法.

Merge commit (multiple parents):

The command used is git merge branchname. It's the default way to merge two branches.

在SmartGit(git merge develop)中通过合并提交develop分支合并到master分支时,提交历史记录将为:

When you merge develop branch into master branch by Merge commit in SmartGit (git merge develop), the commit history will be:

A---B---C---D---M  master
     \         /
      E---F---G    develop

简单提交(一位家长,壁球"):

它使用--squash选项合并两个分支,使用的命令是git merge branchname --squash.

Simple commit (one parent, "squash"):

It merges two branches with --squash option, the command used is git merge branchname --squash.

-南瓜

产生工作树和索引状态,就好像发生了真正的合并(合并信息除外),但实际上并没有使 提交,移动HEAD或记录$ GIT_DIR/MERGE_HEAD(以引起 下一个git commit命令来创建合并提交).这使您能够 在当前分支的顶部创建一个提交,其效果是 与合并另一个分支(如果是章鱼,则更多)相同.

Produce the working tree and index state as if a real merge happened (except for the merge information), but do not actually make a commit, move the HEAD, or record $GIT_DIR/MERGE_HEAD (to cause the next git commit command to create a merge commit). This allows you to create a single commit on top of the current branch whose effect is the same as merging another branch (or more in case of an octopus).

在SmartGit(git merge develop --squash)中通过简单提交develop分支合并到master分支中时,它会将来自develop分支的更改作为新的普通提交(好像发生了真正的合并),并且提交历史将为:

When you merge develop branch into master branch by simple commit in SmartGit (git merge develop --squash), it get the changes from develop branch into master branch as a new ordinary commit (as if a real merge happened), and the commit history will be:

A---B---C---D---M  master
     \                 
      E---F---G    develop

这篇关于合并不带南瓜和带南瓜选项的提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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