-
Notifications
You must be signed in to change notification settings - Fork 217
Fixing Merge Conflicts
Jake Dube edited this page Oct 13, 2016
·
1 revision
###1. Do a git fetch (use whatever remote you are trying to fix on)
git fetch upstream
- You can use this to see what your remotes are linked to (upstream, origin, etc.). I will use upstream for simplicity.
git remote -v
###2. Checkout a new branch from the branch you are merging into. (this is probably develop or master)
git checkout -b explore_conflict upstream/branch_to_merge_into
###3. Try to merge the unmergeable branch (likely a feature branch) into the explore_conflict
branch.
git merge upstream/unmergeable_branch
- Git should show you a conflict error like:
Auto-merging some_file.extension
CONFLICT (content): Merge conflict in some_file.extension
Automatic merge failed; fix conflicts and then commit the result.
###4. Fix the conflict
- Open up your IDE or text editor and find "<<<<<<".
- This is the beginning of a block that Git put to show your merge conflict.
- The syntax Git uses is:
<<<<<< HEAD
* What has been added
======
* What has been removed
>>>>>> upstream/unmergeable_branch
- The goal is to manipulate the code to incorporate all features in a single working project.
###5. Commit your changes.
git add some_file.extension
`git commit -m "Fixed conflict."
###6. Push to remote.
git push upstream explore_conflict
###7. Merge explore_conflict
into the unmergeable branch with GitHub.
- Add a pull request to merge explore_conflict into unmergeable branch
- Merge the pull request
###8. You're done! The merge conflict should be gone.