【问题标题】:Git: Merge in branch without polluting the Master historyGit:合并分支而不污染主历史
【发布时间】:2013-10-01 16:50:33
【问题描述】:

好吧:

在 svn 和 bzr 中,我可以分支、提交、合并,我的提交历史将如下所示:

41: Theodore R. Smith 2013-09-14 Jump to list by name instead of number.
40: Theodore R. Smith 2013-09-14 [merge] [m] Miscellaneous cleanups.
  39.1.4: Theodore R. Smith 2013-09-14 [m] Removed old files.
  39.1.3: Theodore R. Smith 2013-09-14 [m] Fixed bug where test could not...
  39.1.2: Theodore R. Smith 2013-09-14 [m] Fixed a CSS layout bug from th...
  39.1.1: Theodore R. Smith 2013-09-14 [m] Fixed a typo.
39: Theodore R. Smith 2013-09-14 Added a progress bar.
38: Theodore R. Smith 2013-09-14 [merge] Updated the core libraries.
  37.1.3: Theodore R. Smith 2013-09-14 Updated HTML Kickstarter.
  37.1.2: Theodore R. Smith 2013-09-14 Upgraded to from jQuery 1.8.3 to 2.0.3.
  37.1.1: Theodore R. Smith 2013-09-14 Upgraded to jQuery Address v1.6.

如果我不想扩展历史,我可以:

41: Theodore R. Smith 2013-09-14 Jump to list by name instead of number.
40: Theodore R. Smith 2013-09-14 [merge] [m] Miscellaneous cleanups.
39: Theodore R. Smith 2013-09-14 Added a progress bar.
38: Theodore R. Smith 2013-09-14 [merge] Updated the core libraries.

在任何时候,我都可以通过bzr diff -r37.1.2..37.1.3 轻松非常获得单个合并提交的差异等。

重要的是我的分支历史保留,并且我的主线提交历史没有被次要功能提交污染。

现在,每当我在 git 中进行功能合并时,无论有没有 --no-ff,我都会在我的提交历史记录中得到以下信息:

<hash>: Theodore R. Smith 2013-09-14 Jump to list by name instead of number.
<hash>: Theodore R. Smith 2013-09-14 [merge] [m] Miscellaneous cleanups.
<hash>: Theodore R. Smith 2013-09-14 [m] Removed old files.
<hash>: Theodore R. Smith 2013-09-14 Added a progress bar.
<hash>: Theodore R. Smith 2013-09-14 [m] Fixed bug where test could not...
<hash>: Theodore R. Smith 2013-09-14 [merge] Updated the core libraries.
<hash>: Theodore R. Smith 2013-09-14 [m] Fixed a CSS layout bug from th...
<hash>: Theodore R. Smith 2013-09-14 Updated HTML Kickstarter.
<hash>: Theodore R. Smith 2013-09-14 [m] Fixed a typo.
<hash>: Theodore R. Smith 2013-09-14 Upgraded to from jQuery 1.8.3 to 2.0.3.
<hash>: Theodore R. Smith 2013-09-14 Upgraded to jQuery Address v1.6.

我的问题很多。

  1. 功能次要提交在主线历史记录中全部。什么鬼?
  2. 功能次要提交在主线历史记录中混乱。似乎他们是根据他们原来的提交时间而不是合并时间卡在那里的;o
  3. 修订 ID 没有即时的数字排名,只有随机散列。但我敢打赌,这无法解决。
  4. 基于此,我不知道功能分支在哪里结束或开始。

我想要一个解决方案

  1. 保留所有提交历史记录,并让我区分次要功能提交。这是代码取证所需要的。所以git rebasegit merge --squash 一样不存在。
  2. 不会污染主线提交日志。这可能是最严重的。
  3. 根据合并时间保持所有提交的正确顺序。拜托,我不能有混合匹配的小提交。
  4. 最好让我至少以正确的顺序查看所有次要功能提交以及主线历史记录,例如 bzr 是如何做事的,但我不介意只能通过钻头查看此信息-指挥,如git log

感谢您帮助我理解这个过于复杂的程序!

【问题讨论】:

标签: git version-control git-merge bazaar


【解决方案1】:

Git 和 Bazaar 的图是一模一样的,我知道是因为我写了 Git 官方的 Bazaar 桥,唯一的区别是通过log 命令来呈现图。

git log 有大量选项,因此可以准确指定您希望该图表如何呈现。

看起来你想要的是这样的:

git log --oneline --graph

这将以与 bzr log 类似的方式向您显示合并:

*   eaaec50 Merge git://github.com/git-l10n/git-po
|\  
| * 1b5f46f l10n: Add reference for french translation team
| * 6b388fc l10n: fr.po: 821/2112 messages translated
* |   2809258 Merge branch 'sb/mailmap-updates'
|\ \  
| * | cdb6b5a .mailmap: Combine more (name, email) to individual persons
| * | 10813e0 .mailmap: update long-lost friends with multiple defunct addresses
* | | 8ed205a git-remote-mediawiki: ignore generated git-mw
| |/  
|/|   
* |   96cb27a Merge branch 'maint'

你也可以完全忽略“次要提交”

git log --oneline --first-parent

eaaec50 Merge git://github.com/git-l10n/git-po
2809258 Merge branch 'sb/mailmap-updates'
8ed205a git-remote-mediawiki: ignore generated git-mw
96cb27a Merge branch 'maint'

如果您厌倦了键入所有这些选项,您可以配置一个别名:

git config --global alias.l 'log --oneline --graph'

所以你可以输入git l

【讨论】:

  • 为什么这不是默认设置?特别是在 github 上:o
  • 非常感谢!我终于有了一个可用的 git log ;o 它不能与 github 一起使用,但是哦,对吧?
  • 更好的是,您可以使用--decorate 选项。
猜你喜欢
  • 2016-01-11
  • 1970-01-01
  • 2021-03-11
  • 2015-04-17
  • 1970-01-01
  • 2018-05-28
  • 1970-01-01
  • 2015-07-24
  • 2014-05-08
相关资源
最近更新 更多