Skip to content

Git Remove Remote File and Stop Syncing

Accidentally uploaded the db.sqlite3 file in a Django project. Follow these steps to fix this:

  1. Remove the file from staging area (index), but keep the file in working directory
git rm --cached ./proj/db.sqlite3
  1. Check file status. You will see the file marked as "deleted" (in staging area) and "untracked" (in working directory)
git status

# Sample output
# On branch master
# Your branch is up to date with 'origin/master'.
# Changes to be committed:
#   (use "git restore --staged <file>..." to unstage)
#         deleted:    proj/db.sqlite3
  1. Commit this delete operation. From now on, Git will no longer track this file, but your local file remains.
git commit -m "remove db.sqlite3"
  1. Important! Add this file to .gitignore
# db.sqlite3
db.sqlite3

Released under the [BY-NC-ND License](https://creativecommons.org/licenses/by-nc-nd/4.0/deed.en).