Git:在分支中合并而不会污染主历史

The*_*ith 3 git version-control bazaar git-merge

好的:

在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.
Run Code Online (Sandbox Code Playgroud)

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

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.
Run Code Online (Sandbox Code Playgroud)

在任何时候,我可以得到的diff等,为个体合并提交相当容易的,通过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.
Run Code Online (Sandbox Code Playgroud)

我的问题很多.

  1. 该功能次要提交的所有在主线的历史.我勒个去?
  2. 功能次要提交在主线历史记录中混乱.看来他们根据原来的提交时间而不是合并时间而停留在那里; o
  3. 修订版ID没有立即的数字排名,只有随机哈希值.但我打赌那不可修复.
  4. 基于这一点,我不知道功能分支的结束或开始的位置.

我想要一个解决方案

  1. 保留所有提交历史记录,并允许我区分次要功能提交.这是代码取证所必需的.因此git rebase,原样是不合适的git merge --squash.
  2. 不污染主线提交日志.这可能是最严重的.
  3. 根据合并时间,遵守正确的所有委托书.拜托,我不能轻微提交混合匹配.
  4. 最好让我至少以正确的顺序查看所有次要功能提交以及主线历史记录,就像bzr如何处理事情一样,我不介意只能通过钻取命令查看此信息,喜欢git log.

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

Fel*_*peC 11

Git和Bazaar的图形完全相同,我知道因为我写了Git的官方Bazaar桥,唯一的区别是图表是如何通过log命令呈现的.

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

看起来你想要的是这个:

git log --oneline --graph
Run Code Online (Sandbox Code Playgroud)

这将以类似的方式向您显示合并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'
Run Code Online (Sandbox Code Playgroud)

您也可以完全忽略"次要提交"

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'
Run Code Online (Sandbox Code Playgroud)

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

git config --global alias.l 'log --oneline --graph'
Run Code Online (Sandbox Code Playgroud)

所以你可以输入git l.