Welcome back to the Reference Guide series.
Merging is the act of integrating code changes from another branch into a working branch. With 'Git', there are times when competing changes cannot be resolved without intervention. Conflicts can occur when someone edits a file and someone else deletes the same file, or, when changes are made to the same line of the same file.
Merge conflicts can be a bit intimidating at first but rest assured they won't be for long. After a little practice, you'll be a pro in no time.
RESOLVE MERGE CONFLICTS
Once changes have been pushed to the branch name it’s a good practice to follow a few more steps to resolve potential conflicts before making a
pull request in GitHub.
git pull origin master
- This command updates the local branch to match the master branch.
Open a code editor of choice to review changes or conflicts. Generally,
current changes will be highlighted in one color and
incoming changes will be highlighted in a different color. Accept the
incoming changes. Once completed run the following commands:
git add –A
git commit –m “add comment description of changes made”
git push origin <name of branch>
Up next: Pull Requests
For the completed Reference Guide Series:
- Part One: Reference Guide: Common Commands for Terminal.
- Part two: Create a GitHub Repository
- Part three: Committing Changes
- Part four: Committing Changes with Branches -Part five: Merge Conflicts
- Part six: Pull Requests
- Part seven: Conducting a Code Review -Part eight: Complete and Merge a Pull Request