Skip to content

Latest commit

 

History

History
24 lines (19 loc) · 2.63 KB

2_Working_Push_Conflicts.md

File metadata and controls

24 lines (19 loc) · 2.63 KB

Working Through Push Conflicts

  • When working with a local copy of the remote repository, if you don't pull down changes frequently, you're not going to have the latest image of the repo, with all the latest updates made by other contributors.
  • At this point, if you try to push changes to the remote repository, you're going to get an error that says your updates were rejected because the remote contains work that you do not have locally.
  • To check the status of your local working branch relative to the remote one, run git status.
  • To integrate the remote changes into your local branch, run git pull.

Merge Conflicts

  • Merge conflicts happen when you merge branches that have competing commits, and Git needs your help to decide which changes to incorporate in the final merge.
  • Often, merge conflicts happen when people make different changes to the same line of the same file, or when one person edits a file and another person deletes the same file.
  • You must resolve all merge conflicts before you can merge a pull request on GitHub.
  • To resolve a merge conflict, you must manually edit the conflicted file to select the changes that you want to keep in the final merge.
  • There are two ways to resolve a merge conflict:
    • Using the GitHub conflict editor. This is indicated if the merge conflict is caused by competing line changes, uch as when people make different changes to the same line of the same file on different branches in your Git repository.
    • For all other types of merge conflicts, you must resolve it in a local clone of the repository, and then use the command line to push the changes.
  • To resolve a conflict, GitHub performs what is known as a reverse merge. This means that the changes from the main branch are merged into your current working branch. This allows you to test the resolved code on your branch before you merge it into main. The main branch should be treated as production ready, bug-free code.
  • Resolving a merge conflict on GitHub.
  • Resolving a merge conflict using the command line.
  • Managing merge conflicts learning module from GitHub Learning Lab.

The Project

  • To go deeper in the subject, I took the Managing Merge Conflicts learning module from GitHub Learning Lab. See above for the link to the module. Here's the exercise.