Dvc add: Location of .gitignore File

During dvc add the .gitingnore file is always created at the targets location (with --file the location of the .dvc file can be set but this does not seem to affect the location of the .gitignore file which is created or added to).

This is not always desired, for example one could want a single .gitignore file in a projects root directory.

  1. Did i miss something and there is a way to set the .gitignore file location?

  2. Wouldn’t it be more convenient that the .gitignore location is always the same as the .dvc location (when using the --file argument)?

1 Like

This behavior is not currently configurable. Please feel free to open a feature request on our github regarding specifying the .gitignore location.

Was this issue ever addressed?
I feel like my repository is starting to get cluttered with many .gitignore files.

i did not open a feature request, so likely nothing happend

Hello,
I think you have make sure that the .gitignore file is created at a specific location when using DVC, you can manually move the entries to your project’s root .gitignore file after running dvc add. Alternatively, use a script to automate this process or create a symbolic link from the desired .gitignore location to the target location. DVC does not currently allow setting the .gitignore file location directly with the --file argument.