1

I have three branches of a project, development, testing and production. Each branch needs an xml file, with different contents for each branch. Is there a way of telling git to keep the file around, but when merging branches, ignore that file?

Matt
  • 33
  • 2

2 Answers2

3

That implies that you don't have just one file, but three. Instead of foo.xml: foo-dev.xml, foo-test.xml, and foo-prod.xml, for example.

Ryan Stewart
  • 126,015
  • 21
  • 180
  • 199
  • You could also have a single file with three sections rather than three files, but the basic answer here is correct. There's no way to do what the original question describes, so you'll need to handle it another way. – Emily Jul 25 '11 at 16:18
  • Another way to handle it would be to have a build procedure to copy over the correct file. – Ryan Lundy Jul 25 '11 at 16:21
  • @Kyralessa: I don't see how that would help with the source control problem of having the same file with different content in three different branches. – Ryan Stewart Jul 25 '11 at 16:38
  • Because you could have three files with three separate names, and the build copies over the correct file and gives it the standard name. You have foo-dev.xml, foo-test.xml, and foo-prod.xml, and the build copies the right one to foo.xml for the current build configuration. – Ryan Lundy Jul 25 '11 at 17:07
  • Okay, yeah, I agree. That's what I meant. I thought you were suggesting it as an alternative instead of adding information. Sorry :) – Ryan Stewart Jul 25 '11 at 19:20
0

You can put your xml file in to your .gitignore file

$echo <your xml file> >> .gitignore

Your .gitignore should be under your 3 git repository

TheOneTeam
  • 25,806
  • 45
  • 116
  • 158
  • If the OP does this then the file won't be in their repository. It sounds like they want it there, just not merged – JaredPar Jul 25 '11 at 16:19