-1

I have an opensrc project on bitbucket- https://bitbucket.org/ijabz/jaudiotagger/src/master/README.md

I have some pull requests by contributors to review.

In the past I have just checked the code and then merged the code into the remote master branch on Bitbucket using the Merge button. But these pull requests are too complex for that I need to merge with my local master branch on my computer, build and test it, and then only if okay merge it into the remote master branch.

But I dont know how to do this ?

Paul Taylor
  • 13,411
  • 42
  • 184
  • 351
  • Do you have access to their branch? – ignacio Oct 07 '21 at 14:46
  • You know the name of the pull request branch, right? So fetch it and merge it and test it. – matt Oct 07 '21 at 14:46
  • @matt I need you to break that down for me – Paul Taylor Oct 07 '21 at 14:48
  • Just like https://support.atlassian.com/bitbucket-cloud/docs/resolve-merge-conflicts/ except that there isn't any merge conflict to resolve, you're merging in order to test locally. – matt Oct 07 '21 at 14:56
  • i cant follow that, too general. if you write me an answer I can use I will give you a 100 bounty – Paul Taylor Oct 07 '21 at 15:21
  • tried git checkout mvmn/generics_refactoring didnt recognize it – Paul Taylor Oct 07 '21 at 18:56
  • the git commands are so unituitive once you get away from commit, push and pull – Paul Taylor Oct 07 '21 at 18:58
  • The problem is that the branch you want to merge is not in *your* repository at all yet; it's only in the contributor's fork. You'll need to add that repository as another remote, and *then* you fetch the branch and merge your master in to the branch for testing. – chepner Oct 07 '21 at 19:55
  • @chepner thanks i think your right conceptually, the link matt gave doesn't have that at all. But isn't it possible for someone to list the full set of commands in an answer – Paul Taylor Oct 07 '21 at 19:58
  • @PaulTaylor yes it does, I presume this is a forked repo and the link has a section "Resolving the conflict between Git forks" – matt Oct 07 '21 at 20:53
  • @matt there is nothing in there about setting up a remote which it seems i have do according to everyone else – Paul Taylor Oct 07 '21 at 20:56
  • No, because they assume you can access the forked repo on Bitbucket directly, in your browser. And that seems like a perfectly reasonable assumption. – matt Oct 07 '21 at 21:00
  • and can I ? - no idea what that means – Paul Taylor Oct 07 '21 at 21:00

3 Answers3

1

The branch you want to merge isn't part of your repository yet; it's only in the contributors repository. You'll need to create a new remote first.

git remote add mvmn ... # You'll need the contributor's fork's URL
git remote update mvmn
git checkout -b pr69 --track mvmn/generics_refactoring
git merge master

After you are done testing, you can delete the generics_refactoring branch (after checking out another branch, of course)

git branch -D pr69
chepner
  • 497,756
  • 71
  • 530
  • 681
0

Whoever did the pull request has the changes in one branch feature, for example. If you can do git fetch <your remote>, then the branch feature will be available for you. Now, you should run git checkout <your master branch>, just in case you are not there, then run git merge feature.

With that done you should be able to run your tests locally before merging the feature branch in your remote master

ignacio
  • 1,181
  • 2
  • 15
  • 28
  • I want to check https://bitbucket.org/ijabz/jaudiotagger/pull-requests/69 so tried git fetch mvmn/generics_refactoring it gave error for me ? – Paul Taylor Oct 07 '21 at 18:53
  • if you run `git fetch ` and then run `git branch -a`, can you see `generics_refactoring`? – ignacio Oct 07 '21 at 19:01
  • if you can't see it, try [fetching from someone's fork](https://stackoverflow.com/questions/9153598/how-do-i-fetch-a-branch-on-someone-elses-fork-on-github) – ignacio Oct 07 '21 at 19:08
  • when you say im not entirely sure what the value is meant to be, i assume it was the name of the user/brach i was interested in, but maybe it is isnt. – Paul Taylor Oct 07 '21 at 19:11
  • I mean something like `origin`, what is the output of `git remote show`? – ignacio Oct 07 '21 at 19:29
  • ive upated question with output – Paul Taylor Oct 07 '21 at 19:36
0

I took another approach. I cloned their repository and then checkedout a remote branch locally

git clone https://ijabz@bitbucket.org/mvmn/jaudiotagger.git
git checkout origin/generics_refactoring

Then I can test their new code, and view it in my IDE

Then if it is okay I can approve the request on BitBucket and that will handle any merge conflict problems (although there arent any in this case), and I can just delete the cloned repository as I no longer need it.

This may not seem the most elegant solution but at least I just about understand it.

Paul Taylor
  • 13,411
  • 42
  • 184
  • 351