The Atlassian Community Forums are currently in read-only mode. We will be relaunching on a new platform on September 22 (read more here). We apologize for the extended downtime. For concerns or questions, please email communitymanagers@atlassian.com. See you on the other side, on the new Atlassian Community Forums! :)

×

Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to fetch/clone an unmerged pull request

Fabian Mendez
April 17, 2018

How do I fetch a pull request in Bitbucket?

In github it's possible to do this with:

git fetch origin pull/1/head

Based on this I tried with:

git fetch origin pull-requests/1/head

 

But it says:

fatal: Couldn't find remote ref pull-requests/4/head

 

Thanks in advance!

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

1 vote
Answer accepted
Mikael Sandberg
Community Champion
April 17, 2018

If you want to check out the code that is part of the pull request, all you have to do is

git checkout -t origin/<source branch>

This will create a local copy of the source branch. Note that you may have to do a git fetch first if you do not see the branch when you do git branch -r 

Fabian Mendez
April 17, 2018

The thing is, the code is not from a branch of the main repo it's from a fork

Mikael Sandberg
Community Champion
April 17, 2018

Okay, in that case you need to know the fork URL and you can then use git fetch <forked_repo_url> <branch> to fetch it. Check out How to locally fetch and checkout a pull request

Fabian Mendez
April 17, 2018

OK thanks, it works

But would be great to have a github-like reference to the pull requests

Fabian Mendez
April 18, 2018

Well, There is another gotcha with this solution, if the project/repository is private, whenever someone fork it it will be private too and if I try to fetch a branch from a private repo of another user I get a 'remote: Unauthorized' error

Fabian Mendez
April 20, 2018

To finally work with this the user has to explicitly give permissions to those who want to clone/fetch a PR

TAGS
AUG Leaders

Atlassian Community Events