How to get the commits in a specific branch in stash via REST API.

I use the stash as our SCM.

I want to get the commits in a specific branch.

I go through the REST API for stash. 

My steps are:  logon to stash --> get all of the branched for a specific repository ordered by Last modified --> take the branch name --> set the branch as the default branch --> get the commits in this branch.

But "set the branch as the default branch" this action is very dangerous. 

I think if there were any other solution to get the commits in a specific branch in stash via REST API?

1 answer

1 accepted

I think what you want is the "compare" REST endpoint, with which can get you commits, changes or a diff, between a from & to ref (eg. "master") or commit hash. For example:

https://stash.example.com/rest/api/1.0/projects/PROJECT/repos/myrepo/compare/commits?from=my-branch&to=master

Thanks, Marcin, this solution is just what I want.

what about excluding merge?

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

30,922 views 26 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you