Using Git on DigitalOcean server: error: The following untracked working tree files would be overwritten by merge

Posted September 23, 2021 285 views

I am using Django for my site on DigitalOcean. So, I had to delete the migration files for one of my apps (accounts) and run makemigrations again. I don’t really recall when or why, but it has caused this error when I pull from origin:

$ git pull origin master
error: The following untracked working tree files would be overwritten by 
Please move or remove them before you merge.

Locally, my accounts app has only one migration:

accounts > migrations

When I run git status on the server, I get a lot of untracked files, and I can see two migrations related to my accounts app (even though locally I only have one migration file in the accounts/migrations) as well as other untracked files (not related to accounts app):

On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)

Given that I don’t want to mess with the production database, I don’t wish you to change the migration files on the server to replicate the local migration files unless this does not cause any problem for my server. So, how should I resolve this error?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
1 answer


Indeed, this is quite tricky as this is your production server. It sounds like someone has made changes directly on the production server without going through git. If you are working with a team, I could suggest getting in touch with them too to verify why this has been done.

Alternatively, what you could do is check the content of the accounts/migrations/ migration file on the server and your local environment and verify which is the correct one and update it accordingly.

In general, as there is only 1 file reported to be causing the problem, to solve this particular problem in git, what you could do is revert the untracked changes made to the file with git checkout -- accounts/migrations/ and then pull the latest changes as normal.

However as this is a production environment, I would strongly suggest taking a backup of both your database and files so that in case that anything goes wrong after you merge those changes, you could at least revert back to a working version of the website.


  • Thank you Bobby! I will try that and provide updates. Just a note that no one changed a file on the production server. All the changes made locally, but since all the local migrations were deleted due to a complication and new migrations made, there is a difference between local and production server on that file. One idea is to delete server migrations and do a git pull. Would this damage the data?

    • Hello,

      I believe that if a specific migration has already been executed it should not run again even if there are changes to the migrations file. However as a suggestion, before proceeding, you could test that on your local dev environment, for example, try modifying the existing migration and check your data after that.

      Also, I could suggest again backing up the data to be sure that you could revert in case that anything goes wrong.

      Let me know how it goes!