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

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

1 vote
Answer accepted
Mikael Sandberg
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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 Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
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

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events