1. Bitbucket
  2. Public Issue Tracker
  3. master

Issues

Issue #10057 resolved

Knowing how many commits behind master?

Denis Santaterra
created an issue

Hello,

Do you can help-me?

I need know how many commits my branch behind master. I see in bitbucket web site have feature "Sync now". What command you run in GIT to return this value?

What command you run in GIT to synchronize (Sync branch)?

Please see image in attachment.

Thank you.

Comments (3)

  1. Kaleb Elwert staff

    With git, you can use the rev-list to find all commits that are in one branch and not another.

    For example,

    # List of all commits in feature branch, not in master (Ahead)
    git rev-list feature-branch --not master
    
    # List of all commits in master, not in feature branch (Behind)
    git rev-list feature-branch --not master
    
    # You can append wc -l to each of those to get the number of lines.
    echo 'Ahead:' $(git rev-list feature-branch --not master | wc -l)
    echo 'Behind:' $(git rev-list master --not feature-branch | wc -l)
    
    # EDIT:
    # It's worth noting that there are a number of different ways of notating this... the following is just one more way.
    git rev-list feature-branch..master
    
    # Also, these same notations work with git log, so you can see the full commits that would be merged.
    

    Hope this helps!

  2. Log in to comment