什么是“合并泡沫”? [英] What is a "merge bubble"?

查看:163
本文介绍了什么是“合并泡沫”?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我听说过关于Git的合并泡沫。我对Git相当熟悉,但不认为自己是专家。我听说过一些关于合并泡沫的负面消息。什么是Git中的合并泡沫,它有什么问题,我该如何避免它?

I've heard of "merge bubbles" with regards to Git. I'm fairly well-versed in Git, but would not consider myself an expert. I've heard some negative things about merge bubbles; what is a "merge bubble" in Git, what's wrong with it, and how can I avoid it?

推荐答案

A >合并泡泡在Git中是一个微不足道的合并,不需要解决任何冲突。气泡出现在使用 - 图形选项时显示合并的日志中。例如,如果您运行 git log --graph ,您可能会看到如下所示的内容:

A merge bubble is a "trivial merge" in Git that did not require any conflicts to be resolved. The bubble occurs in the log where the merge is displayed when you use the --graph option. for example, if you ran git log --graph you might see something like this:

| |
* |   commit d79f3c4e129356b055c659ee5be28081c1f38aa1
|\ \  Merge: 09bf1ed 4ef9a23
| | | Author: Peter <peter@example.com>
| | | Date:   Wed Sep 17 17:21:07 2014 -0400
| | |
| | |     Merge branch 'master' of http://fictitiousrepo.visualstudio.com/DefaultCollection/_git/fictitiousproject
| | |
| * | commit 4ef9a2387f0d4db39a6cab8ff8f531815935c305
| | | Author: Andrew <andrew@example>
| | | Date:   Tue Sep 16 11:54:14 2014 -0500
| | |
| | |     updated changelog
| | |
* | | commit 09bf1ed0125d77c26b5760939c125998bb046e9a
|/ /  Author: Peter <peter@example.com>
| |   Date:   Wed Sep 17 17:20:30 2014 -0400
| | 
| |       fixed some bugs

其中线条膨胀为合并泡泡。这看起来似乎无害;但许多人认为它比可能发生的可读性要低得多,如下所示:

where the lines "bulge" out is the "merge bubble". This may seem innocuous; but many consider it much less readable than what could have happened, which would be like this:

|
* commit 09bf1ed0125d77c26b5760939c125998bb046e9a
| Author: Peter <peter@example.com>
| Date:   Wed Sep 17 17:20:30 2014 -0400
|
|     fixed some bugs
|
* commit 4ef9a2387f0d4db39a6cab8ff8f531815935c305
| Author: Andrew <andrew@example>
| Date:   Tue Sep 16 11:54:14 2014 -0500
|
|     updated changelog
|

...因为不需要 merge 真的是必需的。

...because no merge was really required.

这通常会在通过自动合并来接受拉取请求时发生。有时候,这是由于合并请求按钮在Github上的工作原因。

This generally happens when accepting a pull request by automatically merging it. Sometimes this was due to the how the "Merge Pull Request" button used to work on Github.

为了避免合并带有请求的气泡,一种策略是手动合并。例如:

To avoid merge bubbles with pull requests, one strategy is to manually merge. For example:

git checkout master
git remote add remoteorigin git://remotegithost.com/remotegitrepo/remotegitproject
git fetch remoteorigin 
git merge remoteorigin/remoteprojectbranch
git push origin master

要从拉取请求中移除最近提交的合并泡泡(当您尚未推送时),一种策略是首先存储当前更改,将头部重置为泡泡前的提交,拉动拉丁,然后按下。例如:

To remove a recently committed merge bubble from a pull request (when you haven't pushed), one strategy is to first stash your current changes, reset your head to the commit before the bubble, pull with rebase, then push. For example:

git stash save
git reset --hard HEAD~1
git pull --rebase
git push origin HEAD

参考:
http://adammonsen.com/post/1172

这篇关于什么是“合并泡沫”?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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