Git: ignore .ext1 file only if file.ext2 exists

To be precise, there is a project with a bunch of * .el and * .org files. When executed, a file is generated from each file file. .Gitignore is now written. Is there a way to say that any file.el should only be ignored if the .org file is present, otherwise track file.el

This does not solve the problem. Also doesn't write every file to .gitignore

+3


source to share


1 answer


Not with gitignore (I don't know the rules for conditional ignore).

A workaround would be a bash script (works even on Windows) that:

  • find all file.el

  • for each file, check if file.org

  • if so use git update-index --no-assume-unchanged file.el



(or git skip-worktree --no-assume-unchanged file.el

: see " The difference between" assume-unchanged

"and" skip-worktree

"
"

But, as commented, it would be easier to decouple the generate from the dist files, with only the former to be ignored.

+1


source







All Articles