# Using .gitconfig in a collection

**URL:** <https://forum.ansible.com/t/using-gitconfig-in-a-collection/43309>\
**Category:** Collection Development\
**Tags:** vmware\
**Created:** [June 11, 2025, 4:32pm UTC](https://forum.ansible.com/t/using-gitconfig-in-a-collection/43309 "2025-06-11T16:32:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mariolenz](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mariolenz/32/108_2.png) [@mariolenz](https://forum.ansible.com/u/mariolenz)\
**Post date:** [June 11, 2025, 4:32pm UTC](https://forum.ansible.com/t/using-gitconfig-in-a-collection/43309/1 "2025-06-11T16:32:20Z")

</div>

I’ve seen a `use "\n" for line endings instead of "\r\n"` error [here](https://github.com/ansible-collections/community.vmware/actions/runs/15553481596/job/43825155370?pr=2315).

I wonder if it’s a good idea to have a `.gitconfig` file in the repo that makes sure that EOLs are already `\n` and not `\r\n`? I think a `.gitconfig` in a repo can override global git config automatically so people don’t have to use this explicitly.

What would be the best way to implement this, and do other collections do this? Do you see any drawbacks to this approach?

---

<div class="post-metadata">

**Author:** ![pavel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/pavel/32/3845_2.png) [@pavel](https://forum.ansible.com/u/pavel)\
**Post date:** [June 15, 2025, 12:41pm UTC](https://forum.ansible.com/t/using-gitconfig-in-a-collection/43309/2 "2025-06-15T12:41:55Z")

</div>

Hi!

I’d rather use linter on pre-receive or something similar, but if you’d like to go client-side than maybe use `.gitattributes` instead. You can commit it in repository and it will be respected.

So something like below should do:

```auto
* text eol=lf

```

This way anyone staging with CRFL will get a warning that files will be converted and then conversion will take place on commit.

If you like to read more about this have a look [here](https://docs.github.com/en/get-started/git-basics/configuring-git-to-handle-line-endings?platform=mac) or [here](https://git-scm.com/docs/gitattributes#_end_of_line_conversion).

The trouble I have with solution using `.gitconfig` (and most client side solutions) is that anyone who clone the repo need to include it manually. And we all know how easy is to forget to do even the basic things 🙂 So the best action to take is require no action from others ☀

---

<div class="post-metadata">

**Author:** ![kks](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/kks/32/10352_2.png) [@kks](https://forum.ansible.com/u/kks)\
**Post date:** [June 15, 2025, 1:04pm UTC](https://forum.ansible.com/t/using-gitconfig-in-a-collection/43309/3 "2025-06-15T13:04:30Z")

</div>

Simple solution to really annoying problem. I’ve encountered it recently.  
Thank you, Pavel
