Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

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?

share|improve this question

1 Answer

I prefer having versioned:

  • a template file settings.py.tpl
  • a value file per branch: settings.py.branch1 in branch1, settings.py.branch2 in branch2, ... (meaning, no merge issue ever: each value file remains untouched)
  • a script able to detect the current branch, take the right value file and build from the template file the final settings.py (which is private to your working tree: it is never versioned)

That script can be automatically called through a content filter driver which will, on checkout, build the right config file.

smudge

A .gitattributes file can register that 'smudge' script for the settings.py.* files.
(no need for a 'clean' script on checkin)

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.