Please commit your changes or stash them before you merge, commitstash
Preface
Recently, gitlab has been used for version control and collaborative work. It is not very familiar with the use of git, and git is only used in the git bash command line, summary of bugs encountered during git usage
Problem:
The following occurs when git pull is used:
Error: Your local changes to the following files wocould be overwritten by merge: xxx/xxx. java Please, commit your changes or stash them before you can merge. Aborting
Most of these problems are due to conflicts that occur when files are modified and code is not submitted to the remote repository in a timely manner.
There are two ways to solve this problem (cainiao like me prefer the second solution, mainly because I don't need to think too much ):
1. stash Method
Git stashgit pullgit stash pop
2. Discard local modification and overwrite it directly
Git reset -- hardgit pull
I usually choose the 2 method, because my approach is:
If you are not sure, back up the locally written code first, and then I will give up the local modification and pull a copy from the server, then, overwrite the file I want to modify, and then proceed.
Git add. git commit-m "xxx" git push origin master
It is not a pleasure to solve the problem by submitting it to gitlab.