2

Inside my application I do have a server.inc file which contains a switch statement $server=1 that specifies the server the app is installed in.

Now everytime I git push to staging or production that file also gets transfered and I have manually to update the variable on the entire cluster.

I know I could simply exclude this file from git, but then I would not have it under version control.

How could I overcome this problem? Is there a way to exclude a secific file from the hook or something similar?

Thank you in advance for any help on this.

merlin
  • 2,717
  • 3
  • 29
  • 59

2 Answers2

1

The usual technique in this case is just copy this file with the name server.inc.example or server.inc.template - anything that makes you think it's a documentation and not a real production file. After that you commit server.inc.example and delete original server.inc from the repository and also add it (server.inc) to .gitignore. Now you only need to walk through your cluster for the last time and set up server.inc files with required values there (or setup some deploy hook, YMMV).

Alexey Shein
  • 7,342
  • 1
  • 25
  • 38
0

It is not possible to exlude single files from a push, because git push works with commits not single files. Once you added/committed a file, it will be pushed.

However, you can make a little workaround forcing git to mark a file as unchanged or changed as you like. This way you can edit contents but tell git not to track the updates:

git update-index --assume-unchanged <file>

git update-index --no-assume-unchanged <file>
daniel451
  • 10,626
  • 19
  • 67
  • 125