How to solve the conflict of Git merger
This article introduces the relevant knowledge of "how to solve the conflict of Git merger". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!
Merging is not just a simple operation of adding and removing files. Git also merges changes.
$git branch* master$ cat runoob.php
First, we create a branch called change_site, switch over, and change the runoob.php content to:
< ?phpecho 'runoob';?>Create a change_site branch:
$git checkout-b change_siteSwitched to a new branch 'change_site'$ vim runoob.php$ head-3 runoob.php
< ?phpecho 'runoob';?>$git commit-am 'changed the runoob.php' [change_site 7774248] changed the runoob.php 1 file changed, 3 insertions (+)
Submit the changes to the change_site branch. Now, if we switch back to the master branch, we can see that the content is restored to what we modified (empty file, no code), and we modify the runoob.php file again.
$git checkout masterSwitched to branch 'master'$ cat runoob.php$ vim runoob.php # modified as follows: $cat runoob.php
< ?phpecho 1;?>$git diffdiff-- git a/runoob.php b/runoob.phpindex e69de29..ac60739 100644 Mustang-a max runoob.phphands @-0meme0 + 1mem3 @ +
< ?php+echo 1;+?>$git commit-am 'modify Code' [master c68142b] modify Code 1 file changed, 3 insertions (+)
Now these changes have been recorded in my "master" branch. Next, let's merge the "change_site" branch.
$git merge change_siteAuto-merging runoob.phpCONFLICT (content): Merge conflict in runoob.phpAutomatic merge failed; fix conflicts and then commit the result.$ cat runoob.php # opens the file and sees the conflicting content
< ?php>Change_site? >
We merge the previous branch into the master branch, and a merge conflict occurs, and then we need to manually modify it.
$vim runoob.php $cat runoob.php
< ?phpecho 1;echo 'runoob';?>$git diffdiff-- cc runoob.phpindex ac60739,b63d7d7..0000000--- a _ Runoob.php _ circle @-1 _
< ?php +echo 1;+ echo 'runoob'; ?>In Git, we can use git add to tell Git that the file conflict has been resolved
$git status-sUU runoob.php$ git add runoob.php$ git status-sM runoob.php$ git commit [master 88afe0e] Merge branch 'change_site'
Now we have successfully resolved the conflict in the merger and submitted the results.
This is the end of the content of "how to solve the conflict of Git merger". Thank you for your reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!