Recommand · September 2, 2021 0

gitignore not ignoring changes to folder with heroku

I have a flask heroku app that uploads files to a folder and allows users to view those files.

Essentially, once a file is uploaded, it saves it into static/uploads.

However, everytime I publish new changes with git add ., git commit -m "changes", git push heroku master, it resets the static/uploads folder without the files that have been uploaded on the heroku app. This is happening because the static/uploads folder on my local that I am committing is empty.

I want the folder on the heroku server to keep all the files in it, even after I publish the new changes. To do this, I tried adding static/uploads into my .gitignore file however this did not help…

Can someone please help…?

You first need to remove static/uploads from both production and local.

  • Commit the changes after removing the folder
  • Add static/uploads to .gitignore
  • Create static/uploads again and then commit the changes

Note:
You’ll lose all your files, i would suggest to keep a backup first, once the folder starts getting ignored, you can then add the files again