1

I want to track a file that has a constant called Build_Number, and I initialize it to 1.

Whenever I build my project, I increment Build_Number.

However, because this file is tracked, it shows up in my working copy as modified.

I followed this guide: http://blog.pagebakers.nl/2009/01/29/git-ignoring-changes-in-tracked-files/

and used this command git update-index --assume-unchanged <file>

However, this appears to only configure my local git configuration. And I don't want to make everybody that pulls down run this command so that they don't have a modified file every time they build.

Is there another way to, in a way, impose this update-index onto the file so that my coworkers won't have a modified file every time they build?

A O
  • 5,516
  • 3
  • 33
  • 68
  • You could include a bootstrap script in the project that generates the file. That way the bootstrap script doesn't change and the file can be ignored. – Roman May 20 '15 at 19:39

2 Answers2

3

Is there another way to, in a way, impose this update-index onto the file so that my coworkers won't have a modified file every time they build?

Yes: define a content filter driver, more specifically a clean script which will, on git commit, restore the original content of the update-index file.

clean filter

(image shown in "Customizing Git - Git Attributes", from "Pro Git book")

That way, as far as git diff or git add are concerned, the file never change (its content is always '1', because of the clean script being run automatically)
But you can still modify that file locally.

You associate the filter to the file though a .gitattributes declaration. That filter references a bash script which can be asimple as 'echo 1' (to restore the original content)

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • VonC can i please get your email? i tried to find it all over the place and i cant find it. I would appreciate if you can ping me nirgeier@gmail.com – CodeWizard May 21 '15 at 07:16
-1

You can add it to the ignore file .gitignoreand have it added manually every time you wish to.

.gitignore

my_builf_file

Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167
  • If I add it to the `.gitignore`, how would my coworkers get access to the file initially? – A O May 20 '15 at 19:15
  • So... you mean like e-mail my coworkers with the file so they can manually add it? – A O May 20 '15 at 19:16
  • Nope, you can add it to the repo whenever you want and they will get it in the next update, and you can always send email to update them but its not a recommended way ofcourse – CodeWizard May 20 '15 at 19:26