Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7513251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T00:07:21+00:00 2026-05-30T00:07:21+00:00

When you merge two branches together, git creates a separate commit with a message

  • 0

When you merge two branches together, git creates a separate commit with a message like Merge branch 'master' into my-branch.
For a non-trivial merge it is clear to me that this is useful: It keeps the history of how things were merged separate from any other changes. But when the merge is trivial (for example when the two branches don’t affect any files in common), what is the purpose of the separate merge commit?

You can avoid that commit with git merge --no-commit. You could then add a “real” change on this commit too. That way you avoid a seemingly useless extra commit. But the man page warns about this:

You should refrain from abusing this option to sneak substantial changes into a merge commit. Small fixups like bumping release/version name would be acceptable.

Why is that?

With commits with real changes in them marked as o and merge-only commits as X, this is the difference between these two situations:

o---o-o-o---o--- master
 \   \   \   \
  o-o-X-o-X-o-X-o--- my-feature


o---o-o-o---o--- master
 \   \   \   \
  o-o-o---o---o--- my-feature

Why is the first one preferred over the second one?

PS: Assume my-feature is a public branch that other people also use, so rebase would not be an option.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T00:07:24+00:00Added an answer on May 30, 2026 at 12:07 am

    I think there are several reasons why having separate merge commits is a good idea, but it all comes down to the basic rule, that every commit should contain changes that belong together.

    Possible situations where you will benefit from having separate merge commits:

    1. You’re trying to find out which commit introduced a bug. If you don’t separate merging and normal commits, it’s hard to figure out whether the merge caused that bug, or the actual changes from that commit.
    2. You want to revert a change made by a commit. What should happen when you’re reverting a commit that is a merge and also contains changes on its own? Do you want to revert just the changes, or just the merge, or both? If only one of them, how to separate them?

    As added benefit, you get history that’s easier to understand. (You could get history that’s even easier to understand if you used rebase, but you said that’s not possible.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So we've gotten a git branch into a tricky state: Two branches: * master
How can you merge two branches in git, retaining necessary files from a branch?
I've got two branches that are fully merged together. However, after the merge is
I have two branches in my Git repository: master seotweaks (created originally from master
I'm trying to merge two branches together using mercurial and there are some conflicts.
Suppose that I hav two git branches; branch_one and branch_two . If I merge
I am using git and I have two branches: production and master. At this
I'm trying to combine code on two branches with the 'git merge' command, but
Is there any way of simulating a git merge between two branches, the current
I want to merge two branches that have been separated for a while and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.