- Some one on your project has merged a Pull Request into the
masterbranch. - You push your code to your remote branch named
branch_nameand open a Pull Request to themasterbranch. - GitHub informs you your code can not automaticly merge into the
masterbranch.
- Navigate to your project in your shell (the command line).
$ cd /path/to/your/project
- Make sure you are in the correct branch.
$ git branch
git will list local branches and put a * infront of the branch you are in
- Make sure you have notthing to commit. If you have un commited changes, commit them.
$ git status
nothing to commit, working directory clean
- Update local copy of origin repository
$ git fetch origin
- Merge local copy of
origin/masterinto your local branch calledbranch_name.
$ git merge origin/master
git will tell you what files have failed to automaticly merge
- Open the files with conflicts in your text editor.
- In each file with conflict delete the code that is unwanted.
- In each file Update the code to reflect the correct changes.
- Delete the lines that say
<<< HEAD,====, and>>> master - Delete lines from
masteror yourbranch_namethat are unwanted.
<<<<<<<<<<< HEAD
this is where the conflicting code from your branch is
===========
this is where the conflicting code from the master branch is
>>>>>>>>>>> master - RUN YOUR CODE.
- This is possibly the most important step!
- Just becuse you "handled" your merge conflict does not mean your haven't broken your app.
- Add your changes and commit.
$ git add .$ git commit -m "handled merge conflict from master"
- Push to your
branch_nameon origin.
$ git push origin <branch_name>
- Your Pull Request should be able to merge!