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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T11:31:41+00:00 2026-06-08T11:31:41+00:00

I found this answer already: Number of commits on branch in git but that

  • 0

I found this answer already: Number of commits on branch in git
but that assumes that the branch was created from master.

How can I count the number of commits along a branch without relying on that assumption?

In SVN this is trivial, but for some reason is really difficult to figure out in git.

  • 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-08T11:31:42+00:00Added an answer on June 8, 2026 at 11:31 am

    To count the commits for the branch you are on:

    git rev-list --count HEAD
    

    for a branch

    git rev-list --count <branch-name>
    

    If you want to count the commits on a branch that are made since you created the branch

    git rev-list --count HEAD ^<branch-name>
    

    This will count all commits ever made that are not on the branch-name as well.

    Examples

    git checkout master
    git checkout -b test
    <We do 3 commits>
    git rev-list --count HEAD ^master
    

    Result: 3

    If your branch comes of a branch called develop:

    git checkout develop
    git checkout -b test
    <We do 3 commits>
    git rev-list --count HEAD ^develop
    

    Result: 3

    Ignoring Merges

    If you merge another branch into the current branch without fast forward and you do the above, the merge is also counted. This is because for git a merge is a commit.

    If you don’t want to count these commits add --no-merges:

    git rev-list --no-merges --count HEAD ^develop
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I found this answer to this question https://stackoverflow.com/a/7244888/1473523 , but in my situation am
While trying to answer this question I found that the code int* p =
I looked around but haven't found an answer to this. I have a CentOS
Sorry if this answer is already on this site, but I've looked all over
I hope I'm not asking something that's been already answered (but I found no
First, yes I have searched already and found this answer already: GWT JSNI -
I already checked this answer , but the example does nothing else than show
I found this answer and it sounds like almost exactly what I'm doing. I
I have found this answer really useful. It helps me plot network/graphs and select
I found this question which had an answer to the question of performing batch

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.