git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: How do I see “merge events” in history?

From
Jeff King <peff@peff.net>
Date
May 23, 2017, 12:20 UTC
Message-ID
<20170523122046.xfxudxqof726vzuj@sigill.intra.peff.net>
In-Reply-To
<CAJtFkWu25RkiKm0O__W2My+Adi9pxZ3YtjZW4eb+2U+wpNS3yA@mail.gmail.com>
On Tue, May 23, 2017 at 03:07:40PM +0300, Stefan Monov wrote:
Show 7 quoted lines
> I use the GitHub web interface and the git cli. Answers for either or
> both are appreciated.
> 
> Sometimes, when I merge a branch into another branch, I see a commit
> with a message like "Merge branch 'master' into other_branch" in the
> GitHub history. But not always. So how do I see all "merge events",
> inside the history?

The simple answer is that to see all merges, you can run "git log --merges". But I think that's not quite what you're asking.

Your "but not always" makes me think you are wondering why sometimes when you run "git merge" (or "git pull), it results in a merge commit and sometimes not, and whether you can see evidence of the times when it was "not".

When a merge is a "fast forward", i.e., when the thing you are merging is strictly a descendent of your current branch, then Git omits the merge commit and simply updates your current branch tip to the thing you're merging. This can happen if you forked a branch, and then when it came time to merge it back, nothing had happened on the original branch.

In a fast forward merge, there's no evidence at all of the merge command in the resulting history graph. So there's nothing to find via "git log".

For some workflows you'd rather see a commit for such merges, even if it could fast-forward. For example, when merging a topic branch, you may want the graph to reflect that the work was done on a side branch, even if nothing happened on "master" in the interim. You can use "git merge --no-ff" for this.

> Even better if I can get a view with vertical lines showing branches
> and merges (like a graph).

Try "git log --oneline --decorate --graph". It will show you the graph structure and annotate the tips of any branches.

-Peff
Previous: Stefan Monov
Message 2 of 2 in “How do I see “merge events” in history?”
  1. Stefan MonovMay 23, 2017
  2. Jeff KingMay 23, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.