I have tried to resolve the merge conflict after pulling both source and destination & merging in my local repo. After conflicts are cleared and the commit is done. I'm getting pre receive hook error message, when pushing the commit to source. As the source branch should be modified only though pull requests.
How can I create a pull request for source branch to resolve the merge conflict.
On your local, after completing the merge, push it up using a new branch name. PR that into source (preferably using --ff-only for a cleaner graph), then PR that into destination using the original PR.
You can push current state up as a new branch like so at any time:
git push origin HEAD:refs/heads/branch-with-new-name
Here's my detailed instructions. Note: merges are symmetric, and so I prefer to "git checkout DESTINATION; git merge SOURCE" to do the merge, since it keeps the commit graph cleaner. I also prefer to do this work in detached head state to avoid perturbing anything else that might have been going on in my local cone. That's why I do the checkout from "origin/DESTINATION" instead of "DESTINATION" - to force detached head.
1. Do the merge and resolve the conflicts:
git fetch
git checkout origin/DESTINATION
git merge origin/SOURCE
# resolve conflicts
git commit
2. Push the merge up as a new branch:
git push origin HEAD:refs/heads/branch-with-conflicts-resolved
3. Create new PR in Bitbucket and merge it.
Source: branch-with-conflicts-resolved
Destination: branch
Choose: "--ff-only" merge from drop-down merge dialog (if available).
4. Return to original PR and merge it. :-)
Here's more info on keeping the graph clean: Protect our Git Repos, Stop Foxtrots Now!
If you're on Bitbucket Server, I recommend installing my add-on, Bit-Booster - Rebase Squash Amend, for the "All Branches Graph", which I find very helpful in situations like this. The integrated graph on Bitbucket Cloud achieves the same thing.
p.s. To merge with "--ff-only" you might need to adjust Bitbucket's Merge Strategies for the given repo (or, even better, using the higher-level project settings). But this might only apply for users on Bitbucket Server. You didn't mention if you're on Bitbucket Server or Bitbucket Cloud.
Thank you this helped.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
A big thank you
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.