3

Say you have a develop branch and a master branch (master corresponding to production). In the develop branch you might have a test folder, a scripts folder that you want to version control.

But every time you merge the develop branch with new changes to the master branch, you want to ignore scripts and tests, because master branch has exactly the same files that are in production (so that you could even automatically deploy the master branch in every merge).

What's the best way to achieve that? There should be a way to merge everything but some 'ignored' folders.

My question is a bit the same as this one. But I am surprised that is a not very popular question. I think this is a problem every developer that wants to be able to deploy automatically and is testing code will have to face

Community
  • 1
  • 1
de3
  • 1,890
  • 5
  • 24
  • 39

2 Answers2

2

Create a .gitattributes file in master with

test merge=ours
scripts merge=ours

Note: I haven't actually been able to test this, because apparently .gitattributes with merge=ours does not work on msysgit.

Klas Mellbourn
  • 42,571
  • 24
  • 140
  • 158
0

Another approach (from my old answer) is to use content filter driver declared in .gitattributes file.

filter driver

That would allow, on checkout, to generate the right script or config file, from the combination of template files and value files.

You would keep all value files (for master or dev) in the same directory: no need to merge them (they are different).
The common files are generated, so they are not versioned (not merged either)

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