[英]Git: Do commits on local, merged branch get pushed to remote?
Assume I have the following git history假设我有以下 git 历史
L1 - L2 - L3 <- Local branch
/ \
A - B - C -- D -- E -- M <- master
where L1, L2, and L3 are commits on my local branch and M is the merge commit into master.其中 L1、L2 和 L3 是我本地分支上的提交,M 是到 master 的合并提交。
Now, when I push my changes to remote, will the commits in the local branch be part of the history or not?现在,当我将更改推送到远程时,本地分支中的提交是否会成为历史记录的一部分? In other words, will the history in the remote repository look like the graph above or just like
换句话说,远程存储库中的历史记录会像上图还是像
A - B - C - D - E - M <- master
Also: What happens in the case of fast-forward merges?另外:在快进合并的情况下会发生什么?
A merge commit has two parent commits.合并提交有两个父提交。 You cannot just cut out the commits of the local branch from the history.
您不能只是从历史记录中删除本地分支的提交。 M cannot exist without L3, L3 cannot exist without L2, and so on.
M没有L3就不能存在,L3没有L2就不能存在,依此类推。 This integrity is a fundamental to Git.
这种完整性是 Git 的基础。 So the pushed
master
branch will necessarily "look like a graph", the commits on the local branch won't vanish into thin air.因此,推送的
master
分支必然“看起来像一张图”,本地分支上的提交不会凭空消失。
In a fast-forward merge, nothing special happens.在快进合并中,没有什么特别的事情发生。 The history is linear.
历史是线性的。 It's not really a merge, it's really "just fast-forward".
这不是真正的合并,它真的是“快进”。 In your example, suppose there are no commits D and E, you merge the local branch, then the history becomes:
在您的示例中,假设没有提交 D 和 E,您合并本地分支,则历史记录变为:
A - B - C - L1 - L2 - L3 <- master
Notice that there is no M either (no merge commit).请注意,也没有 M(没有合并提交)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.