Difficulty: Beginner
Estimated Time: 10 minutes

In this scenario you will learn how you can share the changes in your repository with other people and combine their changes in your own repository.

To help complete this scenario, a repository has been created with a remote repository attached. The environment has simulated that another developer has worked on the same file as you. As a result, when you pull their changes you find that a conflict between both of your changes. This scenario explains how to resolve this conflict.

In this scenario we've explored the different ways of handling merges. We've seen how to use git fetch and git merge to pull remote changes, how to resolve conflicts with other commits and finally how to keep our git log and commits clean using git rebase. Merging is an important part of Git, a topic we'll explore in more depth in future scenarios.

This scenario has been added to your scrapbook where you can review the examples and commands you executed.

Scenario 5 - Fixing Merge Conflicts

Step 1 of 6

Step 1 - Git Merge

The git fetch command downloads changes into a separate branch which can be checked out and merge. During a merge Git will attempt to automatically combine the commits.

When no conflicts exist then the merge will be 'fast-forwarded' and you won't have to do anything. If a conflict does exist then you will retrieve an error and the repository will be in a merging state.


In your environment the changes from a remote repository has been fetched.

You now need to merge the changes from origin/master.

This will result in a merge conflict. The conflict indicates the merge failed because both repositories added the file. We'll resolve this in following next steps.


By keeping commits small and focused you reduce the likelihood of a merge conflict.

The command git pull is a combination of fetch and merge.