Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git pull - Please move or remove them before you can merge

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?

like image 895
Brett Avatar asked Mar 16 '16 15:03

Brett


People also ask

How do I force git pull to overwrite local files?

Just like git push --force allows overwriting remote branches, git fetch --force (or git pull --force ) allows overwriting local branches.

Will a git pull overwrite my changes?

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.

What does git clean do?

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 .


2 Answers

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

like image 65
Neha Avatar answered Sep 27 '22 19:09

Neha


To remove & delete all changes git clean -d -f

like image 43
DURGESH Avatar answered Sep 27 '22 19:09

DURGESH