You may ignore (gitignore) a critical configuration file in a public project because you were checking in passwords by mistake. If you ignore the file, you still need to add the file to the project because others may know they need the configuration, but you shouldn't expect them to remember how to create the complex configuration when they clone your project. Force commit a template for the config file (without passwords) so they can build and run your project.
$ git -a --force src/main/resources/config/application-dev.yml
The ignore will still be respected but you will still have a properly-formatted template config in place for others to use.