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 Basic Merging

Seth Warner
Seth Warner
5,348 Points

At the end of the video "Basic Merging" with Tommy Morgan, git had to resolve an issue, can someone..

explain to me how it resolved this issue. This is the very first git course I've taken and I am only as familiar with git as the videos are previous to this video.

"What did git do to resolve the issue, and why and how did it work".

Seth

Kazuma Namioka
Kazuma Namioka
20,674 Points

Well, it's been a year and a half, but...

By issue, do you mean when the branch foo_feature was merged into the master branch? The README had been changed in both the foo_feature repository after it had been branched off from the master branch, and in the master branch itself, in different ways. Git was being asked to merge two up-to-date files together which were now different from each other, rather than just adding changes made in a current file to an older version.

Because the differences between the two versions of the file were in this case on different lines within the file, Git could resolve the issue itself without further user input by just including all the changes made in both versions. The why: because it's easier this way than manually choosing what changes to the README to keep and which to discard from the two versions. The how: that's the way Git is programmed to deal with text file merges of this nature. I like to think of this as like when Naruto gets the experience and knowledge from his shadow clones when they come back to him. If there's a merge conflict, so a change that Git can't automatically solve itself, it's like the movie The One with Jet Li and the two versions have to fight until a single victor emerges.