0

I have a file settings.py and two branches dev and prod.

In prod the file could look like

DEBUG =False
URLS = ["some_url"]
USERS = ["user1","user2","user3"]
IPS = ["ip1","ip2"]

and in dev

DEBUG = True
URLS = ["some_url","test_url]
USERS = ["user1","user2","user3"]
IPS = ["ip1","ip2"]

Since I always need to have DEBUG=False in prod I would like to be able to chose which "lines" to be merge when I merge/checkout settings.py from dev to prod, instead of open the file after the merge, and set that setting again.

This is of-course a toy-example, in the real file I have several lines I need to keep distinct

CutePoison
  • 4,679
  • 5
  • 28
  • 63
  • 1
    There are many questions about versioning (for example) configuration files that differ per branch or machine or user, with various solutions. Have you tried searching? – CodeCaster Mar 13 '21 at 09:20
  • I have seen different answers around but that is how to checkout specific files and not how to decide **what** in the specific files I need to keep etc. If I can force a "merge-conflict" that would be fine, since I then am able to solve it there – CutePoison Mar 13 '21 at 09:26
  • 1
    If you insist on that, you're looking for the wrong solution. You're going to need branch- or environment-specific files that get merged or renamed during build or deploy, or use environment variables, command-line parameters and do on to determine which file to use. See also https://stackoverflow.com/questions/6557467/can-git-ignore-a-specific-line – CodeCaster Mar 13 '21 at 09:30
  • You cannot *force* a conflict here, which is a problem in general. If you remember, you can use `git merge --no-commit` (and also `--no-ff` if necessary) and manually whack on the merge result before finishing the merge, but this is not a good idea in general as it's too easy to forget. – torek Mar 13 '21 at 14:48

0 Answers0