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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:53:25+00:00 2026-05-22T21:53:25+00:00

Let say I create a branch called foo from master and while working on

  • 0

Let say I create a branch called foo from master and while working on it, I perform a lot of local commits. I am now done with the branch an want to merge it back into master however while I don’t want to squash all commits into just one commit when merging back which I know can be done with:

#from master branch
git merge --squash foo

I stil want to be able to squash some of the commits so that only the important ones are pushed to the origin repository. Now if I know the number of commits I have done since creating the branch, this is easy. All I have to do is:

#assuming I did 20 commits
#while in the foo branch
git rebase -i HEAD~20

And then I can squash the commits I want. The issue is that I generally don’t keep track of the number of times I commit to a branch so if I don’t know that number (and most cases I won’t) I don’t know what to do. Generally I will only need to squash when the branch is done and I am ready to merge back into master so I was wondering if there is a way to get the number of commits since a branch was created?

  • 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-22T21:53:26+00:00Added an answer on May 22, 2026 at 9:53 pm

    I’d simply

    git rebase -i origin/master
    

    or whatever you branched from, so the resulting history will appear I started from later version and the merge back will probably be fast-forward (it’s easier to work with, especially since you are rewriting the actual history to logical changesets anyway). But if you want to keep the same base point, you can do

    git rebase -i $(git merge-base HEAD origin/master)
    

    (or whatever you branched from again).

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

Sidebar

Related Questions

I want to create variables inside a function from a dictionary. Let's say I
Let's say I create two banches at the same time : hg branch branch-A
Let us say I have a trunk and I create a branch (branch A)
Let's say I want to create a lot of custom buttons with the same
Let's say you create a wizard in an HTML form. One button goes back,
Let's say that I create a Sub (not a function) whose mission in life
Let's say that you want to create a dead simple BlogEditor and, one of
Let's say I woke up today and wanted to create a clone of StackOverflow.com,
Let's say I have a payments table like so: CREATE TABLE Payments ( PaymentID
Let's say that I have a Flash website where you could create an avatar

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.