Git: Common solutions to code conflicts

If there are some configuration files in the system that have been modified on the server, and then some new configuration items are added in subsequent development,

When publishing this configuration file, a code conflict occurs:

error: Your local changes to the following files would be overwritten by merge:
        protected/config/main.php
Please, commit your changes or stash them before you can merge.

If you want to keep the changes made on the production server and just incorporate the new configuration items, do the following:

 

git stash
git pull
git stash pop

 

You can then use git diff -w +filename to confirm that the code was automatically merged.

 

Conversely, if you want to completely overwrite the local working version with the files in the codebase. Here's how:

 

git reset --hard
git pull

 

Among them, git reset is for the version. If you want to roll back local modifications to the file, use

 


 
  1. git checkout HEAD file/to/restore  

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325861073&siteId=291194637