Currently, I do not own a personal computer so I often used a computer which was available in the history department to complete the exercises for Crafting Digital History. When I did not have access to that computer, I would use my iPad to make changes to my remote GitHub notes. However, there were times when I forgot to pull these changes to my text editor once I was using the computer again. As a result, when I attempted to sync changes from local to remote I caused a merge conflict.  There is more than one way a merge conflict can occur, in my case, I created an edit conflict. This is the most common type of conflict, and it occurs whenever two branches change the same part of a repository, and then attempt to merge both changes together. As a result, Git does not know which change to use, and asks for you to “resolve the conflict” to clarify which change your want to keep.

Merge Conflict 2016-03-29 at 2.51.45 PM

GitHub offers a useful guide for resolving edit collisions and removed file conflicts from the command line. If you would like to read the guide please click here. Below I will show how I used this guide to resolve my edit conflict. In the command line, run git status to see which file has the conflict and how the conflict occurred.  The command line will also explain how to correct the conflict. In my case, I had more than one file with uncommited changes, which I merged in the command line with git add and git commit -m "updated several files". Also, I had one outstanding conflict in my Notes for Exercise Typography Visualizing Data in Hummanities file.

Command line showing diverged changes

Sync Conflict GitHub Desktop 2016-03-29 at 2.51.11 PM

When this type of conflict occurs, Git adds conflict markers within the affected file in your text editor. Git includes the contents of both versions involved in the edit conflict, allowing you to choose which change to use, or make a brand new change all together.  In my text editor, Notational Velocity (nvALT), Git showed my conflict with my local changes shown under <<<<<<HEAD and my remote changes shown just above >>>>>>>origin/master. The conflicting changes were separated by ========. I deleted the “origin/master” version and removed the conflict markers. In my GitHub desktop I was prompted to Merge remote-tracking branch 'origin/master'. I wrote a commit message, “sync” to origin, and then the conflict was resolved. Alternatively, in the command line you can git add <file-name> then git commit -m "commit-message" and thengit push changes back to the remote GitHub file.

nvALT showing Confict in Text 2016-03-29 at 2.53.04 PM

Everything Merged 2016-03-29 at 3.05.08 PM