Make git ignore generated files

后端 未结 3 1873

I have several projects that have a large number of files that, when processed, generate other files. There is no need to track the generated files, in fact, in some cases you

相关标签:
3条回答
  • 2021-01-22 14:03

    You can't do that with the .gitignore. You'll want to split generated files and user files into separate folders, and ignore the whole generated folder.

    0 讨论(0)
  • 2021-01-22 14:12

    See if you can put the generated files in a special folder say tmp. Then you can just add this folder in .gitignore

    tmp/

    0 讨论(0)
  • 2021-01-22 14:26

    Several simple solutions:

    • Add all suffixes (e.g. .pdf) to .gitignore as *.pdf, and git add -f those version-this-one.pdf that should be versioned, git will keep track of those (need a bit of care). The *.pdf is really a glob, so you could exclude, say, PDFs whose hames start with uppercase by [A-Z]*.pdf.
    • As above, but add e.g. *.pdf for all PDFs, and !version-this-one.pdf to exclude one from the excluded set (can also use a pattern here)
    • Make a complete list of the generated files into .gitignore. Need to keep it up to date (not too bad, if a new one shows up, git will consider it untracked, just add it then).
    • Mix and match: Use the above methods as you want for different filename patterns
    • Per directory .gitignore: git searches first in this directory's .gitignore, if not found in the parent's, ... As you can exclude patterns with !, this stops a search there.

    Check out gitignore(5).

    0 讨论(0)
提交回复
热议问题