1

I have two branches for development and deployment. I made committed some changes to the deployment branch which I wanted to merge into the development branch. Now I expected the merge command to show a conflict in such cases -

//development
$path = 'localhost';

and

//deployment
$path = 'example.com';

Instead what happens is that the deployment branch line just replaces the development branch line. I can cherry pick the commits and apply them to the development branch or make the changes manually but I thought there must be a better way to do this.

Vishal
  • 490
  • 5
  • 11

2 Answers2

0

It will only conflict if you had of changed it in the development branch as well. So because you only changed it in Deployment its just a normal version change.

Simply don't commit that particular file in your changeset. (assuming that you made no other changes in that file)

Tim Jarvis
  • 18,465
  • 9
  • 55
  • 92
  • Yes, I didn't change it in the original. In this particular case there are other minor changes in the file, it would be nice if there was a way to avoid doing manual edits as it is possible for configuration files to vary a lot. – Vishal May 19 '12 at 00:27
0

Since that configuration file varies a lot, it is best to completely avoid any merge issue for this type of file.

You should versions the values of that config file in separate files:

  • config_dev.values
  • config_depl.values

And you would have only one versioned config.template file with placeholder for the values:

// server name for dev or deployment or other environments
$path = '@@SERVER_NAME@@'

That way, this template file doesn't change and won't be merged.
You would also version a script able to, on checkout, generate the actual config file (which wouldn't be versioned, remaining "private", ie only local to your current working directory)

content filter driver

If you declare that script as a content filter driver in a .gitattributes file, it will be executed automatically on git checkout, and will look for a file it recognizes as your config.template file (the script isn't pass any file name or file path, it only gets the content of each checked-out files)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250