Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Development Tools Git Basics Working With Remote Repositories Pushing and Pulling

Aakash Srivastav
Aakash Srivastav
Full Stack JavaScript Techdegree Student 11,625 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 90,705 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. :)