Error: your local changes to the following files would be rewritten by merge solution

The background,
Other members of the team have modified a file and submitted it for storage. You modified the local file before pull. When you modify the code and pull again, the following error will be reported:
error: Your local changes to the following files would be overwritten by merge
Ii. Solutions
Depending on whether you want to save local changes, there are two solutions
2.1 Reserved modification
Execute the following three commands

git stash
git pull origin master 
git stash pop 

Note:
Git Stash: Back up the current workspace, read from the last commit, and make sure the workspace is the same as the last commit. At the same time, save the contents of the current workspace in Git stack. Git Pull: Pull the current branch code on the server. Git Stash pop: read the last saved contents from Git stack and restore relevant contents of the workspace. At the same time, users may perform stASH operations for many times, and need to ensure that the first stash is fetched after, so the stack (in and out) is used for management. Pop the top of the stack and restore the Git Stash List: Shows all the backups in the Git stack, and you can use this list to decide where to restore. Git Stash Clear: Clears the Git stack
2.2 Scrap modification
The core idea is to roll back the version, as follows

git reset --hard 
git pull origin master

Note: The second type is not recommended. Unless you’re sure you don’t need a local change.

Read More: