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:
- Git solves pull origin error: the following untracked working tree files would be rewritten by merge
- error: Your local changes to the following files would be overwritten by merge
- error: The following untracked working tree files would be overwritten by merge
- Error: You have not concluded your merge (MERGE_HEAD exists)
- You have not concluded your merge (MERGE_HEAD exists)
- The local network card cannot be obtained by opening Wireshark
- Solution to the incomplete display of big data files printed by pychar
- Please specify which branch you want to merge with
- Solution: when cmake is compiled, “error in configuration process project files may be invalid” appears
- The too many open files solution appears in stream classes such as files.list
- Solution: Rsync error: some files could not be transferred (code 23) at main. C (702)
- Solution to Apple Wireless Mouse, keyboard or touchpad can not be recognized by MAC
- Android:Field can be converted to a local varible.
- [SharePoint] after deploying webpart, the solution to the resource file in the layouts mapping directory referenced by webpart cannot be found
- Resolving fatal: reusing to merge unrelated histories in Git
- Local workspace file (‘angular.json’) could not be found.
- Git uploads local IntelliJ idea project to GitHub
- fatal: refusing to merge unrelated histories
- Python Anaconda Spyder can’t display pictures by using Matplotlib. Error report solution: figures now render in the plots pane by default. To mak
- Fatal: reusing to merge unrelated histories