The reason for error messages like these is rather simple: you have local changes that would be overwritten by the incoming new changes that a "git pull" would bring in. For obvious safety reasons, Git will never simply overwrite your changes.
Will git pull erase my changes?
Never pull before you commit any valid changes. This will wipe off all your changes. To retain your code, you have to commit, then pull, then finally push. First pull the code(hard reset also maybe, as I do it sometimes) from repo to your local directory.
How do I pull git without losing local changes?
- In .git/info/sparse-checkout , define what you want to keep. ...
- Tell git you want to take sparse-checkout into account. ...
- If you already have got this file locally, do what git does on a sparse checkout (tell it it must exclude this file by setting the "skip-worktree" flag on it)