I have a django project and I am using git.
I need to have a different settings.py file for each branch.
I tested adding settings.py to .gitattributes with merge = ours, but this did not work, because if it does not have a Git conflict, it will merge normally.
Also, add settings.py to .gitignore, this is not an option, because if I change something in settings.py, I want it to move to one branch.
Is there a way to ignore the file when merging, but still click it?
UPDATE:
I tried the VonC solution and I created two settings: settings_production.py and settings_development.py.
So, I installed gitpython and used it in my .py settings, like this:
from git import Repo import os r = Repo(os.path.realpath(os.path.dirname(__file__))) if r.active_branch.__str__( == 'master': from settings_production.py import * else: from settings_development.py import *
And it worked great.
Fernando freitas alves
source share