Using FileMerge to resolve conflicts

Default software is sometimes the best way to go

The use different comparison tools can be a tricky decision. However FileMerge is bundled with Xcode and uses easy navigation, syntax-based colouring and the ability to merge in changes.


  • Some knowledge of Git


Git: Git is a distributed version-control system for tracking changes in source code during software development

Create a remote on github

In the top right hand corner of (assuming you have an account: if you don’t, create on before continuing with this guide)

Image for post
Image for post

Create a suitable repository name (test is a good choice) and then create the repository:

A decent repository name for this tutorial

And we initialize this repository with a README:

Image for post
Image for post

Create a local git repository

Create a suitable folder, for example test within documents (these commands can be run from anywhere using the terminal)

$ cd ~/documents

$ mkdir test

cd test

$ git init

Create a file

$ touch

Make changes to the readme file on your local machine

type the following into, using Xcode or your favourite editor:

Image for post
Image for post

Stage and Commit changes

$ git add .

$ git commit -m “readme commit”

Add the remote to the Git repository in the terminal

you can find the link for the repository through the Clone or download green button, available from the main repository screen (most easily accessed by pressing the repository name in the top-left hand corner of the screen)

Image for post
Image for post
Pressing the repository name (“test”) beside the name of you GitHub repository takes you to the main repository screen
Image for post
Image for post
At the main screen you should see Clone or download, at the top right hand corner of the screen. You can then copy and paste the address from here

Then within the terminal you can add the remote:

git remote add origin

Make changes to the readme file on web repo

Click on README.MD in your web browser

We can then edit the by pressing the pen symbol at the right-hand side of readme

Image for post
Image for post

and we create at the three lines of text as follows:

Image for post
Image for post

remembering to press commit at the bottom of the screen.

Pull information using terminal

remembering to add the unrealated histories as below. This is because we have created the remote, and the master branch on our computer entirely seperately.

$ git pull origin master — — allow-unrelated-histories

You have now created a conflict

Image for post
Image for post

We can move to using opendiff to solve the merge conflicts

$ git mergetool

If we have typed the two files correctly, we will have two differences.

We want to choose the left hand side for the first change (the local), and the right-hand side for the second change.

I find this easiest by using the cursor keys (up and down to choose the difference, left to will make the arrow face left and we choose the left hand version and the right will do the reverse). The result of the changes will be shown in a third window at the bottom of the screen.

Image for post
Image for post
The completed choice of the changes in

An alternative is under actions you have choices as to whether choose left, right, both (left first), both (right first) or neither.

Image for post
Image for post

In either case, you must save the changes when you close the file (so click save).

Back in the terminal you must confirm that the merge was successful (and of course you can check this in your text editor).

Image for post
Image for post
The prompt asking if your change was successful

If you say no to this question, you will be left with lots of temporary files that you will need to choose w

Cleaning up changes

If your change was successful, most of the temporary files are removed from your folder, with only one remaining ( To remove this we can clear any untracked files

$ git clean -f

or, if we are unsure which files are tracked (and do not want to go to the trouble of a git status to check it), we can remove just that specific file

$ git rm

Committing changes

$ git commit -m “readme changes”

then to be able to push set the upsteam master, and push the changes

$ git push — set-upstream origin master

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store