- Some one on your project has merged a Pull Request into the
master
branch. - You push your code to your remote branch named
branch_name
and open a Pull Request to themaster
branch. - GitHub informs you your code can not automaticly merge into the
master
branch.
- 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/master
into 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
master
or yourbranch_name
that 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_name
on origin.
$ git push origin <branch_name>
- Your Pull Request should be able to merge!