如何在GitHub上进行快速合并? [英] How to do a fast-forward merge on GitHub?

查看:68
本文介绍了如何在GitHub上进行快速合并?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我的一位同事尝试使用GitHub在网络界面中的通过快进合并"选项合并分支,以使历史记录免受伪合并提交的影响( master 分支自合并对象功能分支启动以来,它们一直没有进展.

So one of my colleagues attempted to merge a branch using GitHub's "merge via fast-forward" option in the web-interface, to keep the history clean from bogus merge commits (the master branch into which they merged, had not progressed since the to-be merged feature-branch was started).

很有趣的是,这并没有按预期的那样工作:所有的提交都有新的提交哈希.

Funnily enough, this didn't work as expected: all the commits got new commit-hashes.

仔细检查后,似乎合并选项实际上称为"Rebase and Merge",并且确实看起来与 git rebase --force 等效,更改了 Committer 信息(进行合并的人以及发生合并的时间).

On closer inspection, it seems that merge-option is actually called "Rebase and Merge" and it really seems to do the equivalent of git rebase --force, changing the Committer information (both the person who did the merge, and the when the merge happened).

我花了相当长的时间来确认我的怀疑确实如此,因为我无法使用cmdline工具向我展示功能分支上原始提交与看似相同的提交之间的区别(使用主分支上的不同哈希值).(最后,我发现 gitk 同时显示提交的提交者和作者;在非常端,我发现我也可以通过 git获取此信息.log --pretty = raw )

It took me quite a while to confirm my suspicion that this is indeed the case, as I couldn't make the cmdline tools to show me the difference between the original commits on the feature branch and the seemingly-identical commits (with different hashes) on the master branch. (In the end, I found that gitk shows both Committer and Author of a commit; in the very end I found that I can also get this information via git log --pretty=raw)

所以:

  • 是否有一种方法可以进行适当的"快速转发合并( git rebase 而无需 -force 选项)通过GitHub的Web界面?
  • 如果不是:为什么?(我可以看到问责制的优点;例如,它回答了由谁负责给定代码最终以 master 结尾的问题)
  • Is there a way to do a "proper" fast-forward merge (git rebase without the --force option) via GitHub's web-interface?
  • If not: why? (I can see merits in accountability; e.g. it answers the question who is responsible that a given piece of code ended up in master)

推荐答案

基于GitHub的文档和我自己的测试,不可能使用相同的提交哈希进行快速转发.

Based on GitHub's documentation and my own testing, it is not possible to do a fast-forward with the same commit hash.

GitHub上的rebase和merge行为与git rebase略有不同.在GitHub上进行重新基准化和合并将始终更新提交者信息并创建新的提交SHA,而当在祖先提交之上进行重新基准设置时,在GitHub外部的git rebase不会更改提交者信息.有关git rebase的更多信息,请参见"git rebase".Pro Git书中的一章.

The rebase and merge behavior on GitHub deviates slightly from git rebase. Rebase and merge on GitHub will always update the committer information and create new commit SHAs, whereas git rebase outside of GitHub does not change the committer information when the rebase happens on top of an ancestor commit. For more information about git rebase, see the "Git rebase" chapter from the Pro Git book.

https://docs.github.com/en/github/administering-a-repository/about-merge-methods-on-github

这篇关于如何在GitHub上进行快速合并?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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