24 Handling Conflicts

You can’t develop a project with other developers without generating conflicting versions of code from time to time. Git goes a long way toward helping you resolve those automatically, but sometimes it can’t.

For example, the code shown on the opposite page shows two different solutions to the same problem. You must tell Git how to fix the conflict because it doesn’t know which version is correct. They both make changes to the exact same lines of code. You can find out which file or files have conflicts in two ways: the output from the failed git merge, or git status.

You can find conflicts within a file by looking for <<<<<<<—seven lesser than signs—with a commit such as HEAD. The original code—the ...

Get Pragmatic Guide to Git now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.