How do I merge a Pull Request when develop branch out of date?

Viewed 138

I am trying to merge my develop branch to the master branch via a pull request. On the pull request page, I am getting the message "Branch is out of date. Merge master into **develop **to remedy."

The problem is that no updates have been made to the master branch since develop branched off of it, other than maybe automated repository upgrades.

I attempted to merge master into develop, but received the same message, just with the branch names swapped.

I understand that to resolve the issue I need to merge master into develop first. However, if I open a PR to go from master to develop, I get the same message as before. There is no mechanism to allow me to merge in those changes.

enter image description here

2 Answers

The most common cause of this is squashing commits from feature-branch -> develop and then again squashing between develop and master. This is fairly easy to fix locally using the git command line. You'll need to have git installed on your machine and then you can follow the following steps:

  • Click Clone in the top right and copy the url given. enter image description here
  • Clone the repo: git clone [COPIED URL]
  • Make sure you're on master: git checkout master
  • Create a new branch: git checkout -b fix_merge_conflicts
  • Merge from develop: git merge develop
  • Git will give you a list of files with conflicts, open these and fix the conflicts by removing appropriate lines.
  • Add the fixed files: git add myfile.txt folder/otherfile.py
  • Commit your changes: git commit
  • If the message looks okay, exit the editor (normally vi, so use :wq to exit).
  • Checkout master again: git checkout master
  • Merge in changes from your branch: git merge fix_merge_conflicts
  • Checkout develop: git checkout develop
  • Merge in changes from your branch: git merge fix_merge_conflicts
  • Push all changes back to your Code Repository: git push

This issue occurs usually due to branches being out of date with each other. So branch A would first need to be merged into branch B, and then the pull request from B -> A will show the diff they are expecting.

Sometimes the easiest way to do that is to clone the repo and do it locally. Rather than working purely in the remote environment. To do this you can.

  1. Clone the repo
  2. Create a new branch from Master
  3. Merge Develop into this new branch and resolve any merge conflicts
  4. Merge this new branch into Develop
  5. Merge this new branch into Master
  6. Push changes back to the remote branch
Related