views:

25

answers:

1

I have a lot of files such as JavaScript, HTML, and even C and C header (.h) files which are automatically generated, so they appear in the makefile like

myfile.js:    myfile.js.tmpl

etc. I want all of these target files to be ignored by the version control system. I am using git but this question is not git-specific. Is there a utility or a trick which exists to make the ignore file (like .gitignore) from a makefile?

(If there isn't such a facility, I can make a script to create one, but before I do that I am just checking I haven't missed some obvious tool or method.)

+1  A: 

One way to do this would be to start with a clean checkout, do a build, then run a git status to find out which files are untracked. Add those files (or suitable patterns) to your .gitignore file.

Makefiles can be so complex that the only way to find out what they do might be to actually run them.

Greg Hewgill
That's a good idea but unfortunately doesn't fit my problem. I have stupidly already added these files to version control, and so I need to remove them and then keep them removed.
Kinopiko
@Kinopiko: If your Makefile has a "clean" function, run that followed by `git status` to find out which files are removed by clean. Then you can `git add -u` and `git commit` to remove those files from version control. If you don't have a working "clean" function, you'll have to remove these files manually first.
Greg Hewgill