Question

How do I exclude a file from being updated?

I have my git automatically syncing the files in the repo to my droplet, but I have a database in there and everytime there’s a new update in the repo it also updates the database. Any ideas how to fix it? I also tried adding a .gitignore, I don’t think I did it right though.


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.

KFSys
Site Moderator
Site Moderator badge
January 20, 2025

Heya,

you are on the correct path!

Your .gitignore file should include the relative path to the database file. For example, if your database is named db.sqlite3 and located in the project root, your .gitignore should look like this:

db.sqlite3

If the database is inside a folder, include the folder in the path:

path/to/db.sqlite3

3. Verify .gitignore is Working

After setting up .gitignore, test to ensure Git ignores the database file:

  • Make a change to the database file.
  • Run:
git status
The database file should no longer appear in the list of changes.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.