Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Comments on Conditionally ignore files in git
Parent
Conditionally ignore files in git
I'm using git for LaTeX projects and am in a little dilemma about how to best ignore files.
-
if I add
*.pdf
to my.gitignore
file, I keep forgetting to force add included graphics -
if I don't add it, I keep accidentally adding the compiled documents, which are often quite large and blow up my repository sizes
-
and even if I remember to add specific filename of the compiled pdf to my gitignore, then dozens of them will clutter the ignore files in my bigger repos and I'll need to add ignore files even for the smaller repos for which normally would not need anything special in addition to my global ignore file.
Is there any way to solve this dilemma? Something like automatically ignoring all .pdf
files for which a .tex
of the same name exists?
Post
I'm not familiar with Latex, but it seems the PDFs are generated from the Latex files.
It then seems the real problem is that you are trying to keep source and objects derived from that source in the GIT repository. Ideally, a GIT repository is only for the actual source files (those directly edited by humans). Put the files that are automatically derived from source elsewhere. This can be automated with your build scripts putting derived objects in a different place. That different place could be a subdirectory within the repository that is added to the .gitignore list.
Another possibility is to have a cleaner script that you run before each commit. This script would delete all the derived objects.
Yet another possibility, although I really don't like this one, is to have the cleaner script instead edit the .gitignore file to ignore the known derived objects, based on the existence of particular source files.
2 comment threads