8

Possible Duplicate:
git: can i commit a file and ignore the content changes?

I have a simple problem, and I hope there's a simple solution.

Using Git (and Tower, great app), I have a repository that has a file that everyone needs to download when they clone the repo, BUT that file should never be reuploaded with changes (because it's a configurtion file, with database-specific usernames / passwords, and paths) - the changes are made only when used locally.

What I want to do is ignore whatever change I made locally to that file, so the file won't get updated when I push changes to my repo. How can this be achieved?

It should be noted that:

  1. When I clone the repo, the file shows up, but when I ignore it (local only, not via .gitignore) I have to untrack it, and when I do and push changes back to the server, anyone that clones the repo will NOT download the file << undesired behavior.

  2. If I ignore the file but I DON'T untrack it, the file still shows up in my working directory, waiting to be commited << undesired behavior.

Community
  • 1
  • 1
AeroCross
  • 3,969
  • 3
  • 23
  • 30
  • Indeed. As stated in that link (useful BTW, thanks!) is using git update-index --assume-unchanged (thoroughly explained in here: http://goo.gl/UZi0E). From what I've seen though, there's no way to do this through Tower.app. – AeroCross Apr 07 '11 at 19:37

2 Answers2

10

Commit an example file, gitignore the real name, and have your contributors copy the example into the proper location, then configure it. Alternately, provide a setup script that copies the example and does those steps.

Daenyth
  • 35,856
  • 13
  • 85
  • 124
  • This is a good alternative too (since, in my app, there are not too many configuration files to modify, only 2) - I'm guessing that, for example, Moodle (config-dist.php) and Wordpress (wp-config-example.php, if I recall correctly) use this method in their respective version control systems. – AeroCross Apr 07 '11 at 19:58
-2

This is properly addressed with smudge/clean scripts.

Alternatively, scripts that do the deploy reset the user names and passwords.

Bending tracking and ignoring is not the way to solve this issue.

Hope this helps.

Adam Dymitruk
  • 124,556
  • 26
  • 146
  • 141
  • 2
    Care to give an example? I'm fairly new to Git, so I don't really know what a smudge/clean script is. I also do not understand the "Alternatively, scripts that do the deploy reset the user names and passwords" part. – AeroCross Apr 07 '11 at 19:56