3

Is there any way to tell Git to track a file's existence, but not to track the content of the file? I would like Git to create a file if it doesn't already exist when git pull is run, but to otherwise ignore the file.

This would be highly useful for error_logs ect in a web-app I am developing.

user2121874
  • 171
  • 1
  • 8
  • Maybe you can use [`git annex`](https://git-annex.branchable.com/) for this? I don't know. –  May 31 '14 at 03:58

1 Answers1

2

A native way to do this (beside git-annex) is to:

  • track a file template
  • version a script which is able, on checkout, to generate the file from the file template (if the file doesn't exist yet): that file won't be versioned and will remain private.
    The script knows how to generate that file or from where to copy it.
  • declare in a .gitattribute file a content filter driver: a smudge script which will run automatically on checkout and will reference the script mentioned in the previous point.

http://git-scm.com/figures/18333fig0702-tn.png

(image from "Customizing Git Attributes" " from the Git Book)

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