To update the code with git pull, we encountered the following problems:
error:Yourlocalchangestothefollowingfileswouldbeoverwrittenbymerge :
xxx/xxx/xxx.java
Please,commityourchangesorstashthembeforeyoucanmerge.
Aborting
the tips are very friendly, and the answers from netizens can help me solve the problem directly
1.stash
Usually, if you encounter this problem, you can directly commit your modification; But I don’t want to do that this time
See how git stash does it
git stash
git pull
git stash pop
Next, diff this file to see the situation of automatic merging, and make corresponding changes
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 to recover the related content of the 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, which can be used 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. Abandon local modification and directly cover it
git reset --hard
git pull
Similar Posts:
- [Solved] Git conflict Error: commit your changes or stash them before you can merge
- Please, commit your changes or stash them before you can merge
- Git Conflict error: Your local changes would be overwritten by merge. Commit, stash or revert them to proceed?
- How to Solve Git Error: Your local changes to the following files would be overwritten by merge
- [Solution] fatal: ambiguous argument ‘stash@‘: unknown revision or path not in the working tree.
- Git pull Error: 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)
- [Solved] git pull Error: error: Your local changes to the following files would be overwritten by merge
- Git error: The following untracked working tree files would be overwritten by checkout
- git:Pull is not possible because you have unmerged files [How to Solve]