.gitignoring pdf file only when a tex source is present

Solution 1:

No, I don't see this feature in gitignore man page.

I would rather:

  • ignore all *.pdf in your global .gitignore file
  • run periodically a script updating a .gitignore file in any directory where a pdf file is found without a matching .tex file

    !afile.pdf

That would make the 'afile.pdf' not ignored in that specific directory.