Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Development Tools Git Basics Working With Remote Repositories Pushing and Pulling

Aakash Srivastav
Aakash Srivastav
Full Stack JavaScript Techdegree Student 11,638 Points

Pushing and Pulling

In this video , what I see is "merge conflict" happens when he typed git pull origin new_feature
Now my question is , is the previous videos , He said that -
Merge conflict arises when a file has been edited in both branches . But then two cases arise-

  1. If the changes has been made in different lines , then git is able to accept the changes and perform the merge itself.
    2.But if the changes has been made in the same line , then git has no idea , which change i want and in that case , it rely on us to solve the conflict.
    But , here is case 1, as file has been edited in different lines still git is not able to solve the conflict . Why?

1 Answer

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,250 Points

A merge conflict occurs when there are differences between branches or your remote repository that have not yet been commented but would be overridden if you attempted to commit or push these changes.

When this happens, when say you're attempting to fix a bug, Git will place markers in your code which you then go into and change, and then tell Git you want to accept those changes.

once done it'll create a new path you can then push to your remote repository.

But if you want to avoid merge conflicts completely, just make sure your local branches are up to date with their equivalents on GitHub. And keep creating new commit history rather than attempting to change the past. :)