[git] 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?

This question is related to git git-merge git-pull git-clean

The answer is


If you are getting error like

  • branch master -> FETCH_HEAD error: The following untracked working tree files would be overwritten by merge: src/dj/abc.html Please move or remove them before you merge. Aborting

Try removing the above file manually(Careful). Git will merge this file from master branch.


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


If there are too many files to delete, which is actually a case for me. You can also try the following solution:

1) fetch

2) merge with a strategy. For instance this one works for me:

git.exe merge --strategy=ours master

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


Examples related to git

Does the target directory for a git clone have to match the repo name? Git fatal: protocol 'https' is not supported Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) git clone: Authentication failed for <URL> destination path already exists and is not an empty directory SSL_connect: SSL_ERROR_SYSCALL in connection to github.com:443 GitLab remote: HTTP Basic: Access denied and fatal Authentication How can I switch to another branch in git? VS 2017 Git Local Commit DB.lock error on every commit How to remove an unpushed outgoing commit in Visual Studio?

Examples related to git-merge

Abort a Git Merge Git pull - Please move or remove them before you can merge Git: How configure KDiff3 as merge tool and diff tool Git: How to pull a single file from a server repository in Git? How to resolve git error: "Updates were rejected because the tip of your current branch is behind" error: Your local changes to the following files would be overwritten by checkout Please enter a commit message to explain why this merge is necessary, especially if it merges an updated upstream into a topic branch How to merge specific files from Git branches git remove merge commit from history The following untracked working tree files would be overwritten by merge, but I don't care

Examples related to git-pull

Trying to pull files from my Github repository: "refusing to merge unrelated histories" Git pull - Please move or remove them before you can merge There is no tracking information for the current branch How to unmerge a Git merge? Git: How to pull a single file from a server repository in Git? Why does git say "Pull is not possible because you have unmerged files"? fatal: could not read Username for 'https://github.com': No such file or directory Difference between git pull and git pull --rebase Is it possible to pull just one file in Git? How do I ignore an error on 'git pull' about my local changes would be overwritten by merge?

Examples related to git-clean

Git pull - Please move or remove them before you can merge How to revert uncommitted changes including files and folders? Reduce git repository size