21

Possible Duplicate:
gitignore without binary files

Edit: Dupe of gitignore without binary files

When you compile, say, a Haskell file, (test.hs), using ghc --make test.hs, the result is test.hi and test. I only want to add and commit the source test.hs, while keeping test.hi and test out of the repository but in the same directory as the source file. test is the problem, how do I specify to .gitignore to ignore a compiled file with no extension?

Community
  • 1
  • 1
bgibson
  • 17,379
  • 8
  • 29
  • 45

1 Answers1

5

Just add the filename to your .gitignore file. For example:

$ git ls-files --other --exclude-standard
test
$ echo test > .gitignore
$ git ls-files --other --exclude-standard
$

.gitignore doesn't care about extensions. It just matches patterns.

larsks
  • 277,717
  • 41
  • 399
  • 399
  • 4
    Thanks, considered that but I'm at the start of the project that will have lots of these filenames. Will resort to that if there's no better option. PS - didn't know about ls-files command, though when I run it it still includes .hs and .txt files in the output. Will check out the man page and play with it a bit. – bgibson Sep 30 '11 at 21:15
  • I just used `ls-files` because the output is less verbose, which is nice for this particular example. If you can't identify the files by name or by pattern you're pretty much out of luck. If you can put all your output files in a particular directory you could ignore the directory, or you could programatically generate your `.gitignore` file as part of your build process. – larsks Oct 01 '11 at 00:16
  • I think that will also ignore any directory path that has 'test' in it... – obiwanjacobi Dec 22 '18 at 15:31