![]() I’m happy with the message so I save and quit the message editor. This opens an auto generated merge commit message for me to confirm or edit. git status tells me the command to run: git add index.htmlįinally, I commit to finish the merge: git commit. Then I save the file and return to the command prompt.Īll that’s left is to inform Git that I have finished fixing the conflict. I need to replace the entire section from > with the correct end result. It is now my job to choose either my version or Grant’s version or some combination of the two. It’s labelled with the ID of Grant’s commit. It is labeled “HEAD”, meaning that’s what was on my system when I did the git pull. Git has included both Grant’s and my versions of the line. But what’s this around the tag? Here’s where I need to do some manual conflict resolution. Indeed, Git added Grant’s “footer” class is there. So how do I fix this conflict? I need to open the conflicted file manually. Since Git was able to handle styles.css by itself, that’s already in the “Changes to be committed” section. If I do a git status, I can see the files that need to be manually fixed in the “Unmerged paths” section. Git informs me that I need to resolve this conflict manually. Grant and I both made changes to the line. However, there was one change that Git could not figure out by itself. It’s clever enough to see that this change was on a different line of index.html from my changes so it can bring it in without difficulty. It is also able to handle Grant’s addition of the “footer” class. For example, the file styles.css was changed by Grant but not by me so Git just includes Grant’s change. Some of them it can figure out and handle automatically. Git tries to reconcile Grant’s changes with the changes I just made. That partially worked, but it’s telling me there was a conflict. In order for Git to let me push my changes, I first need to pull down his changes so that my code is in sync with what’s out on GitHub. He added CSS classes to index.html and some rules to styles.css. In fact, my coworker Grant has pushed some styling changes. Apparently another developer has made changes to the master branch since I last pulled. I am making some changes to the text on index.html. Here are the two files at the beginning of the day. Our repository is hosted at GitHub, and in this case we are both working directly on the master branch. We’re starting out with two files, index.html and styles.css. To set the scene, Grant and I are two developers working on a simple web page. This post provides a walkthrough of how to get through two typical Git conflict scenarios. ![]() This happens when multiple developers are making changes in a repository at the same time. One of the most challenging yet common activities development teams run into with Git is resolving merge conflicts.
0 Comments
Leave a Reply. |