Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Fetching commits by hash

jeenuv January 16, 2019

I was after the feature that Gerrit offers: diff the tip of a pull request to past tips. I learn that Bitbucket doesn't have that feature--which is a shame--so I'm trying to get close. I found out a post that suggests using REST API and jumping through all sorts of hoops to extract information from server.

I can view the diff I want locally if I could fetch the commits I need, but I don't seem to be able to do that either. I get:

fatal: Couldn't find remote ref SHA

 Is there any way I can fetch commits I want from the server?

1 answer

0 votes
Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 17, 2019

Hello Jeenu and welcome to the Community!

So we understand how you’re trying to solve this issue, could you please provide a bit more context on the path you want to take? Are you interested in using the REST API or is that not an option in this case?

Could you please provide more detail around how you’re getting to that error you posted?

If what you’re looking for is to use the REST API to access repository commits, we would suggest reviewing the following: Bitbucket Server REST APIs | See “Simple example of retrieving repository commits.” This example shows how to use the REST API to access commits.

If you’re wanting to review the diff based off the commits to GET, then we would suggest reviewing the following: How to diff arbitrary commits using REST API. There is a feature request associated with this document which would allow you to compare commits, you may find that feature request at BSERV-2550.

Further information on how you would like to solve this issue would help us to clarify a path to take. If the documentation reference above is similar to the path you’re taking, then please let us know if it is helpful. Either way, let us know so we may ensure you have what you need to progress forward.

Regards,
Stephen Sifers

jeenuv January 17, 2019

The error I reported is when I did a `git fetch origin COMMIT`, where `COMMIT` is hash of the tip of a pull request.

And example of this would be how Github allows to fetch PRs: https://help.github.com/articles/checking-out-pull-requests-locally/

Bitbucket doesn't seem to version PRs, so I don't know if there are refs that the server expose to fetch previous tips from. In its absence, it'd have allowed to fetch a valid commit by its hash.

jeenuv January 23, 2019

I was waiting for an official word on this - so does a mechanism exist to fetch a PR to my local repository?

Stephen Sifers
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
January 23, 2019

Hello Jeenu,

There was a suggestion submitted similar to your request which discusses fetching pull requests. You may find that suggest at BSERV-3817. Along with this, there is a KB which is for Bitbucket cloud which does support what you’re looking for. You may find that KB at How to locally fetch and checkout a pull request. However, since this is for the cloud product the feature may not be present on server products, this would serve as an incentive to migrate to a cloud instance.

Regards,
Stephen Sifers

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events