I am trying to do a git pull origin master
from my server but keep getting the error:
Please move or remove them before you can merge.
There are no untracked files, but it seems like it has issues with the ignored files for some reason.
I tried running a git clean -nd
to see what would be deleted and it lists a whole bunch of files that are ignored in .gitignore
.
How can I fix this so I can do a pull?
Just like git push --force allows overwriting remote branches, git fetch --force (or git pull --force ) allows overwriting local branches.
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.
Summary. To recap, git clean is a convenience method for deleting untracked files in a repo's working directory. Untracked files are those that are in the repo's directory but have not yet been added to the repo's index with git add .
I just faced the same issue and solved it using the following.First clear tracked files by using :
git clean -d -f
then try git pull origin master
You can view other git clean options by typing git clean -help
To remove & delete all changes git clean -d -f
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With