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 trialSimon Coates
28,694 Pointsgit automerge sounds deeply fraught
Git merges files automatically (or automagically) and an explanation is offered: "Git has detected that there was a merge conflict in this file because it had been edited in both branches. But because we were editing different lines, git was able to just accept both of our changes and perform the merge itself."
This sounds like something that you wouldn't want to happen. If it did it with code or settings files, it seems like it would be splicing together stuff in an unpredictable manner. This seems an immediate problem.
2 Answers
james south
Front End Web Development Techdegree Graduate 33,271 Pointsif you edit the same line in different branches it won't automatically merge and you will be given the opportunity to reconcile the branches and once you do that, its back to normal and merges for you. i don't think it's anything to worry about.
Tommy Morgan
Treehouse Guest TeacherSimon Coates I'm not sure I understand why this wouldn't be desirable behavior. If we're both working in one file - let's say one large class in your favorite programming language - and I make an edit in one function and you make an edit in an unrelated function, isn't it nice that Git will merge those changes together without complaint?
Of course, I should point out that git's merge behavior is, ultimately, very configurable. If this behavior does end up being problematic for you on a regular basis due to the kind of project you're working on, you can disable it and handle all of your merges automatically.
Simon Coates
28,694 Pointsthanks for response. I assume it's more intelligent than i maybe gave it credit. My concern was where you'd left some blank space and then in both branches wrote some code slightly differently that did the same thing (but on slightly different lines). If it regarded them as separate edits, then i though it might splice in code that represented a duplication, and you wouldn't know to examine. Or does this simply not happen? If it's going to be automerging., then the immediate question to me, is 'can i trust it?'
Simon Coates
28,694 PointsSimon Coates
28,694 Pointsthanks for your reply. The tutorial seemed to imply that it would merge both changes simply if the edits were on different line numbers (i included a direct quote). I didn't see any scenario where that would be desired behavior. If that doesn't happen, then excellent.