Missed Team ’24? Catch up on announcements here.

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

Merge conflicts when both source and destination contains pre receive hook

Madhukara gopal rao Sringeri February 5, 2018

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.

1 answer

2 votes
Julius Davies [bit-booster.com]
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 5, 2018

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.

Madhukara gopal rao Sringeri February 7, 2018

Thank you this helped.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events