git merge conflicts with our database file (multiple developers)

Add your database file to .gitignore. Then you can keep it in its current location, but it will not be under version control.


First off, you'll want to remove the database file from your git repository.

git rm <database_file>

To prevent the file from being added to your repository, create a file named ".gitignore" inside your checkout of the repository, add the database file to .gitignore, and add .gitignore to your repository. (Documentation)

To prevent conflicts with settings.py, I also add settings.py to .gitignore. I then create a file called "settings.production.py", which contains all of the settings for the production server, and add it to the repository. On my local checkout, I simply copy this file into settings.py and modify variables as needed. On my production server, I make a symlink to settings.production.py.

ln -s settings.production.py settings.py

WARNING:

  1. If your repository is public, it should never store secret keys, passwords, certificates, etc. You don't want others to have access to these files.
  2. You should also verify that your web server does not serve ".git" folders. A hacker could gain access to your source code if http://example.com/.git is accessible.