Git conflict: commit your changes or stash them before you can merge
When updating the code with git pull, we encountered the following problems:
error: Your local changes to the following files would be overwritten by merge:
*********************************************************
Please, commit your changes or stash them before you can merge.
Aborting
The reason for this problem is that other people have modified xxx.php and submitted it to the version library, and you have also modified xxx.php locally. At this time, if you do git pull, there will be a conflict. The solution is very clear in the above prompt
1. Retain local modification
1) Direct commit local modification — this method is not generally used
2) Through git stash — usually this way
git stash
git pull
git stash pop
Restore the work area to the last submitted content through git stash, and back up the local changes at the same time. After git pull is completed, execute git stash pop to apply the previous local changes to the current work area
Git stash: back up the content of the current workspace, read the relevant content from the latest submission, and make the workspace consistent with the content submitted last time. At the same time, save the current workspace content to git stack
Git stash Pop: read the last saved content from git stack and recover the related content of workspace. Since there may be multiple stash contents, the stack is used to manage them. Pop will read the contents from the latest stash and recover them
Git stash list: displays all the backups in Git stack. You can use this list to decide where to recover from
Git stash clear: clear git stack. At this point, using gitg and other graphical tools, you will find that the original stash nodes have disappeared
2. Discard the local modification – this method discards the local modification and cannot be retrieved
git reset --hardgit pull< br>& lt; br>& lt; br>& lt; br>& lt; br>& lt; br>
Similar Posts:
- Please, commit your changes or stash them before you can merge
- Git Conflict Error: commit your changes or stash them before you can merge. [How to Solve]
- Git Conflict error: Your local changes would be overwritten by merge. Commit, stash or revert them to proceed?
- [Solution] fatal: ambiguous argument ‘stash@‘: unknown revision or path not in the working tree.
- How to Solve Git Error: Your local changes to the following files would be overwritten by merge
- [Solved] Git pull error: You have not concluded your merge (MERGE_HEAD exists)
- Git pull Error: error: Your local changes to the following files would be overwritten by merge:
- Fatal: cannot do a partial commit during a merge
- [Solved] Please clean your repository working tree before checkout
- git:Pull is not possible because you have unmerged files [How to Solve]