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

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?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.


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.

Regards, Bobby