Announcements
Great work on exam 1! Grades will come out Friday (~ish)
No quiz this week (look for one next week)
Be on the lookout for statistics experience assignment instructions
Be on the lookout for project assignment instructions
Resolving merge conflicts
Working in teams includes using a shared GitHub repos. Sometimes things will go swimmingly, and sometimes you’ll run into merge conflicts.
What is a merge conflict?
A merge conflict occurs when a version control system, like Git, is unable to automatically combine changes from different branches during a merge operation because they have conflicting edits to the same part of a file..
.. in short: If you make changes to your document + pull changes from your repo that impact the changes you made… you will get a merge conflict
Goals
Today we will
– Go over how to avoid merge conflicts
– Go over how to resolve merge conflicts
– Go over how the “last ditch effort” method (which we try to avoid, but it’s used in practice)
How to avoid merge conflicts
Pull
How to avoid merge conflicts
When you open a project, Pull down any changes that your colleague could have made and pushed up.
When you are finished working, Render, and Push all changes up to the repo, so you don’t have un-committed changes to your document that may cause a merge conflict later!
How it happens: Demo
If a collaborator has made a change to your repo on GitHub that you haven’t incorporated into your local work, GitHub will stop you from pushing to the repo because this could overwrite your collaborator’s work!
So you need to explicitly “merge” your collaborator’s work before you can push.
If your and your collaborator’s changes are in different files or in different parts of the same file, git merges the work for you automatically when you *pull*.
If you both changed the same part of a file, git will produce a **merge conflict** because it doesn’t know how which change you want to keep and which change you want to overwrite.
What it looks like
Git will put conflict markers in your code that look like:
<<<<<<< HEAD
See also: [dplyr documentation](https://dplyr.tidyverse.org/)
=======
See also [ggplot2 documentation](https://ggplot2.tidyverse.org/)
>>>>>>> some1alpha2numeric3string4
The ===
s separate your changes (top) from their changes (bottom).
Note that on top you see the word HEAD
, which indicates that these are your changes.