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! While you're at it, check out some resources Treehouse students have shared here.

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 Merging Introduction to Merging

Satu Korhonen
Satu Korhonen
3,360 Points

On what basis does Git resolve merge conflicts?

In the video, the teacher stated that Git manages to resolve most merge conflicts on it own. How does Git do this and on what basis?

2 Answers

Git does this by comparing files, if there aren't conflicting changes it will merge, if there are it will tell you to edit the file. EG. hello.txt in main "hello therea"

hello.txt in 2nd "hello thery"

If two things are conflicting such as the y and e in there it will let you decide as it doesn't know what to do.

Satu Korhonen
Satu Korhonen
3,360 Points

ok, thank you, I think I understand. How advanced is this feature? Does it merely compare strings? What would happen f.ex. if two people created a different solution to the same bug and merged their commits? What I am wondering is that would the solution need to be in the same file in the same lines or can git "understand" that they are two conflicting solutions to the same issue?

Git will tell you that they are conflicting and let you solve it yourself, it will be in the merged file and you can change what merge happened.