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 8300077
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:25:01+00:00 2026-06-08T16:25:01+00:00

Is it possible to condense the commits on a branch into a single commit

  • 0

Is it possible to condense the commits on a branch into a single commit prior to merging with the main? I thought this would be a fairly common scenario, but maybe I am not using the right search terms.

I’ll explain the scenario in more detail. Often I would want to make many local commits while working on a change in a branch to ensure I have a comprehensive history of changes. But once through with the changes in the branch, when I am merging to main, I would like to reduce the commits on the branch to a single one and then merge it to main. I do understand that commits are inexpensive in Git, but in some situations, I might just prefer to do this.

*   merge to main
|\
* | commit 2 on main
* | commit 1 on main
| * commit 2 on branch
| * commit 1 on branch
|/
*   branch from main

to be made to look like

*   merge to main
|\
* | commit 2 on main
* | commit 1 on main
| * commit on branch (branch commits flattened to one)
|/
*   branch from main

I’m a novice when it comes to git. If I have erred in the use of terms, I do apologise.

  • 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-06-08T16:25:02+00:00Added an answer on June 8, 2026 at 4:25 pm

    Use interactive rebasing. Find the commit where your branch diverged from master (may using git merge-base; let’s call the commit <diverge>), then

    git rebase -i <diverge>
    

    and an editor will pop up, allowing you to rewrite history interactively. You’ll want to squash commits.

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

Sidebar

Related Questions

Possible Duplicate: Can main function call itself in C++? I found this problem very
I have this code, which I would like to make as small as possible.
Possible Duplicate: How can I understand nested ?: operators in PHP? Why does this:
I'm attempting to condense several SQL calls into one, and wanted to know if
Possible Duplicate: In Vim: How do I delete a word and go into insert
Possible Duplicate: How would I identify if a website originates from a mobile browser?
Possible Duplicate: Split A4 PDF page into two A5 and back again I have
Possible Duplicate: How do I calculate someone's age in C#? Maybe this could be
Possible Duplicate: Array to named variables How can I convert an array like this
Possible Duplicate: When do you use the “this” keyword? If I have the following

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.