Вопрос

OK so:

In svn and bzr, I can branch, commit, merge, and my commit history will look like this:

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.

If I don't want to expand out the history, I can:

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.

At any time, I can get diffs, etc. for the individual merged commits quite easy, via bzr diff -r37.1.2..37.1.3, for instance.

What's important is that my branch history is preserved and my mainline commit history is NOT polluted by the minor feature commits.

Now, whenever I do feature merges in git, however, with or without --no-ff, I get the following in my commit history:

<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.

My problems with this are many fold.

  1. The feature minor commits are all in the mainline history. What the hell?
  2. The feature minor commits are jumbled in the mainline history. It seems they are stuck there based on their original commit time, not merge time ;o
  3. There is no immediate numerical ranking of revision ids, only random hashes. But I bet that's not fixable.
  4. I wouldn't have ANY idea where a feature branch ends or begins, based upon looking at this.

I want a solution that

  1. Preserves all commit history, and lets me diff minor feature commits. This is needed for code forensics. So git rebase is out of the picture, as is git merge --squash.
  2. Does NOT pollute the mainline commit log. This is probably the most severe.
  3. KEEPS ALL OF THE COMMITS IN THE PROPER ORDER, based upon merge time. Please, I can't have minor commits being mixed-matched.
  4. Optimally lets me at least see all of the minor feature commits, in the proper order, along with the mainline history, like how bzr does things, tho I don't mind only being able to view this info with a drill-in command, like git log.

Thank you for helping me understand this overly-complicated program!

Это было полезно?

Решение

The graph of Git and Bazaar are exactly the same, I know because I wrote Git's official Bazaar bridge, the only difference is how the graph is presented through the log command.

git log has tons of options so can specify exactly how you want that graph to be presented.

It looks like what you want is this:

git log --oneline --graph

Which will show you the merges in a similar way as bzr log does:

*   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'

You can also ignore the "minor commits" completely

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'

If you get tired of typing all these options, you can configure an alias:

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

So you can just type git l.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top