I have a django project and I'm using git.
I need to have different settings.py file, for each branch.
I've tested add settings.py to .gitattributes with merge=ours, but it not worked because if it's not having any conflict Git will merge normally.
Also, add settings.py to .gitignore is not an option, cause if I change something in the settings.py, I want it pushed to the same branch.
Is there a way to ignore a file when merging but still push it?
UPDATE:
I've tried VonC's solution and I've created two settings: settings_production.py and settings_development.py.
So, I pip installed gitpython and used it in my settings.py, 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 fine.