![]() If your merge was successful and everything is okay, you can delete this file. Only then Sourcetree is able to recognize that a conflict was resolved an therefore changes the state of the file from conflicted to staged. If you need to do custom changes to the final result feel free to use the editor function of the merged result view and write down your own changes.Īfter you've finished resolving the conflicted file make sure to save and quit the merge tool. You can do this with every conflict in this file one by another. You can click (single toggle) or hold Shift and click (multiple selection) to control which changes make it to the final result. The yellow square is the common base, the purple triangle stands for your local version and the green circle reflects the changes that will be included from the remote file. Usually P4Merge tries to merge all three versions – local, remote and base – of your file, but you can decide what should go into the final result and what should be ignored by toggle the Icon-Buttons to the right of the merged lines. The view underneath the three columns of referenced files will give you the result of the merge. In the middle you'll find the common base of the two conflicted files (left and right). The left one reflects the content of your local working file, the right column shows content of the remote file you've tried to integrate. P4Merge will open up the conflicted file in a new window. To fire up an external merge tool right-click on the conflicted file, goto Resolve Confilicts and choose Launch External Merge Tool. Once a file is marked as conflicted you'll will notice this by the Icon that Sourcetree adds to the file in the list of changed files. Therefore navigate to Diff in Sourcetree's preferences and select P4Merge in the dropdown. The only thing you need to do to get it working correctly is to download and install P4Merge and add it as the preferred external Diff and Merge Tool in the preferences of Sourcetree. One tool that will help you to resolve conflicts is P4Merge. There are plenty of tools out there, that will help you resolve these conflicts visually and that will work well together with Sourcetree. But sometimes there are pretty complex conflicts happening to a file and the conflict markup becomes pretty messy. The example above is pretty simple and you might be able to solve the conflict using a text editor. When a conflict happens, your job is to clean it up. ![]() ![]() So = separates the changes that will cause the conflict. Lines after the = are the changes coming from the other branch. Text after the first marker shows content of your current working file. Git will wrap conflicted areas with a > marker at the end. Let's take a closer look on how a conflict will reflect in markup of your file. Sourcetree will help you to identify conflicted files. Did a merge conflict happen because of a deleted or modified file or did you both add a file with the same name? When a merge conflict happens the first thing you probably should do is to stay cool an figure out what just happend and why. But if two persons change the same lines in the same file on different branches or if one person decides to deletes parts of a file while the other started making changes on it at the same time Git won't know how to solve this situations alone and therefore it will mark this file as conflicted in order to let you know that it is up to you to solve them. Even then Git will be able to figure out how to integrate changes. These situations will most likely happen when two persons worked on the same file on different branches. But there are some cases where you need to tell Git what to do. The good thing about Git is, that it is pretty smart and figures out how to integrate new changes by itself without your help. Doing this you grab the code of another branch an combine it with your current working files. Merging is the process when integrating the codebase of one branch into the one you are curently working with. Git also takes care of most things during merging and even when it comes to conflicts in worst case you'll just handicap yourself and it won't bring your complete team to halt. Git enables you to revert merges, undo things and start from scratch. One thing you should always remember is that you cannot break things because of merging. But still, for a lot of developers there is still one big fear left – Merge-Conflicts You cannot break things But let me tell you that there is almost no way to mess up a project when you follow the suggested Workflow when starting to collaborate on code. Everybody's greatest fear when working with Git or any other Version Control System is to mess it up.
0 Comments
Leave a Reply. |