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

  • SEARCH
  • Home
  • 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 657609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T22:50:35+00:00 2026-05-13T22:50:35+00:00

I’m trying to understand the difference between a squash and a rebase. As I

  • 0

I’m trying to understand the difference between a squash and a rebase. As I understand it, one performs a squash when doing a rebase.

  • 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-13T22:50:35+00:00Added an answer on May 13, 2026 at 10:50 pm

    Both git merge --squash and git rebase --interactive can produce a "squashed" commit. But they serve different purposes.

    • git merge --squash abranch

    will produce a squashed commit on the destination branch, without marking any merge relationship.
    (Note: it does not produce a commit right away: you need an additional git commit -m "squash branch")

    This is useful if you want to throw away the source branch completely, going from (schema taken from SO question):

    git checkout stable
    
              X               stable
             /
    a---b---c---d---e---f---g tmp
    

    to:

    git merge --squash tmp
    git commit -m "squash tmp"
    
    
    # In the following graph, G is d--e--f--g squashed together
    
              X-------------G stable
             /
    a---b---c---d---e---f---g tmp
    

    and then deleting tmp branch.


    Note: git merge has a --commit option, but it cannot be used with --squash. It was never possible to use --commit and --squash together.
    Since Git 2.22.1 (Q3 2019), this incompatibility is made explicit:

    See commit 1d14d0c (24 May 2019) by Vishal Verma (reloadbrain).
    (Merged by Junio C Hamano — gitster — in commit 33f2790, 25 Jul 2019)

    merge: refuse --commit with --squash

    Previously, when --squash was supplied, ‘option_commit‘ was silently
    dropped. This could have been surprising to a user who tried to override
    the no-commit behavior of squash using --commit explicitly.

    git/git builtin/merge.c#cmd_merge() now includes:

    if (option_commit > 0)
        die(_("You cannot combine --squash with --commit."));
    

    • git rebase --interactive

    replays some or all of your commits on a new base, allowing you to squash (or more recently "fix up", see this SO question), going directly to:

    git checkout tmp
    git rebase -i stable
    
       stable
          X----------------G tmp
         /
    a---b
    

    If you choose to squash all commits of tmp (but, contrary to merge --squash, you can choose to replay some, and squashing others).

    So the differences are:

    • squash does not touch your source branch (tmp here) and creates a single commit where you want.
    • rebase allows you to go on on the same source branch (still tmp) with:
      • a new base
      • a cleaner history
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

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.