{"thread":{"id":"41470","subject":"Question about pull-requests","startedAt":"2016-02-22T11:54:15Z","lastAt":"2016-02-23T02:58:35Z","messageCount":4,"participants":["Nagaraj Mandya","Kevin Daudt","Jeff King","fhaehnel"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"278876","messageId":"CAOh0v-WW=hOXw=uTdzkd3afzXCguBHWdaDShwKE3QKqUCOBTzg@mail.gmail.com","threadId":"41470","inReplyTo":null,"subject":"Question about pull-requests","fromName":"Nagaraj Mandya","fromEmail":"nmandya@gmail.com","sentAt":"2016-02-22T11:54:15Z","receivedAt":"2016-02-22T11:54:15Z","isPatch":false,"sender":{"key":"nmandya@gmail.com","avatar":null},"body":"Hello,\n  In our GIT repository, all users are restricted from merging to\nmaster without a pull request. This works well and all developers are\nraising pull requests and merging. However, if there is a merge\nconflict during the merge, we have a problem.\n\n  We follow the instructions provided by Bitbucket and the final step\nis to push the merged code to master to the \"origin\" repository.\nHowever, that steps always fails with the error that pushes can only\nbe made with pull requests.\n\n  How do we work around this problem? We want all pushes to happen\nthrough merge requests but still allow pull requests with merge\nconflicts to get pushed. Thanks.\n--\nRegards,\nNagaraj\n"},{"id":"278885","messageId":"20160222163731.GA4154@ikke.info","threadId":"41470","inReplyTo":"CAOh0v-WW=hOXw=uTdzkd3afzXCguBHWdaDShwKE3QKqUCOBTzg@mail.gmail.com","subject":"Re: Question about pull-requests","fromName":"Kevin Daudt","fromEmail":"me@ikke.info","sentAt":"2016-02-22T16:37:31Z","receivedAt":"2016-02-22T16:37:31Z","isPatch":false,"sender":{"key":"me@ikke.info","avatar":"https://avatars.githubusercontent.com/u/135698?v=4"},"body":"On Mon, Feb 22, 2016 at 05:24:15PM +0530, Nagaraj Mandya wrote:\n> Hello,\n>   In our GIT repository, all users are restricted from merging to\n> master without a pull request. This works well and all developers are\n> raising pull requests and merging. However, if there is a merge\n> conflict during the merge, we have a problem.\n> \n>   We follow the instructions provided by Bitbucket and the final step\n> is to push the merged code to master to the \"origin\" repository.\n> However, that steps always fails with the error that pushes can only\n> be made with pull requests.\n> \n>   How do we work around this problem? We want all pushes to happen\n> through merge requests but still allow pull requests with merge\n> conflicts to get pushed. Thanks.\n\nThe usual way to solve this is to rebase those commits of the pull\nrequests on the updated master. That allows the one who makes the pull\nrequest to solve the issues, and then push the branch again (adding\n--force-with-lease because you've rewritten history). \n\nThis should update the pull request, but now it should be able to be\nmerged without conflicts.\n\nThat way, you are not required to merge locally into master and push\nthat.\n\nThe merge local option will only work if at least someone has rights to\npush to master, but that is a bitbucket question, not a git question.\n"},{"id":"278905","messageId":"20160222213702.GD15595@sigill.intra.peff.net","threadId":"41470","inReplyTo":"CAOh0v-WW=hOXw=uTdzkd3afzXCguBHWdaDShwKE3QKqUCOBTzg@mail.gmail.com","subject":"Re: Question about pull-requests","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2016-02-22T21:37:02Z","receivedAt":"2016-02-22T21:37:02Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Feb 22, 2016 at 05:24:15PM +0530, Nagaraj Mandya wrote:\n\n>   In our GIT repository, all users are restricted from merging to\n> master without a pull request. This works well and all developers are\n> raising pull requests and merging. However, if there is a merge\n> conflict during the merge, we have a problem.\n> \n>   We follow the instructions provided by Bitbucket and the final step\n> is to push the merged code to master to the \"origin\" repository.\n> However, that steps always fails with the error that pushes can only\n> be made with pull requests.\n> \n>   How do we work around this problem? We want all pushes to happen\n> through merge requests but still allow pull requests with merge\n> conflicts to get pushed. Thanks.\n\nThe strategy we use at GitHub (for our internal work, I mean, but which\nwe also recommend to other projects on the site) is to back-merge master\nto the pull request branch and resolve the conflicts there. Then you can\npush that, and the merge of that result to master will always be trivial\n(unless somebody updated master in the meantime, of course).\n\nIn fact, we use the \"protected branches\" feature[1] to disallow any\nnon-fast-forward merges of a pull request into the master branch. We do\nour CI tests on the tip commit of each pull request, and they also must\npass to allow merging. So you would not want to do any real merging to\nbring the PR into master; the merge result hasn't actually been tested!\n\nI don't know offhand whether BitBucket has a similar feature to\nprotected branches, but certainly you can do use the back-merge-and-push\ntrick.\n\n-Peff\n\n[1] https://github.com/blog/2051-protected-branches-and-required-status-checks\n"},{"id":"278960","messageId":"1456196315828-7648733.post@n2.nabble.com","threadId":"41470","inReplyTo":"CAOh0v-WW=hOXw=uTdzkd3afzXCguBHWdaDShwKE3QKqUCOBTzg@mail.gmail.com","subject":"Re: Question about pull-requests","fromName":"fhaehnel","fromEmail":"fhaehnel@atlassian.com","sentAt":"2016-02-23T02:58:35Z","receivedAt":"2016-02-23T02:58:35Z","isPatch":false,"sender":{"key":"fhaehnel@atlassian.com","avatar":null},"body":"From your message I’m guessing you are using Bitbucket Server with branch\npermissions [1]. \nWe’re aware the conflict resolution instructions can not always be followed.\nImproving these is on our backlog\n(https://jira.atlassian.com/browse/BSERV-7561) - feel free to watch/vote for\nthat issue. \n\nFirst, let’s start with the most basic case: a pull request you created is\nconflicted and can’t be merged. \nHere, you can apply Jeff King’s solution and back-merge the target branch.\nAlternatively, you can, of course, rebase the branch too. (Check out\nhttps://www.atlassian.com/git/tutorials/merging-vs-rebasing for more info on\nwhich option to pick and when).\n\nIf you are using cascading merges [2] in Bitbucket Server, there’s a chance\nof conflicts during the merge-cascade, which will generate “Automatic merge\nfailures”.\nIf this happens, Bitbucket will create a new pull request on your behalf.\nThe same strategy as above can be applied: merge the target branch and\nresolve the conflicts, or rebase.\n\n\n[1]\nhttps://confluence.atlassian.com/bitbucketserver/using-branch-permissions-776639807.html\n[2]\nhttps://confluence.atlassian.com/bitbucketserver/automatic-branch-merging-776639993.html\n\n- Felix\n\n\n\n--\nView this message in context: http://git.661346.n2.nabble.com/Question-about-pull-requests-tp7648649p7648733.html\nSent from the git mailing list archive at Nabble.com.\n"}]}