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