Investigation: Enforcing Git LFS for all users of a project
<!--IssueSummary start-->
<details>
<summary>
Everyone can contribute. [Help move this issue forward](https://handbook.gitlab.com/handbook/marketing/developer-relations/contributor-success/community-contributors-workflows/#contributor-links) while earning points, leveling up and collecting rewards.
</summary>
- [Work on this issue](https://contributors.gitlab.com/manage-issue?action=work&projectId=278964&issueIid=384331)
- [Close this issue](https://contributors.gitlab.com/manage-issue?action=close&projectId=278964&issueIid=384331)
</details>
<!--IssueSummary end-->
This is an action item from an [internal discussion about Git LFS](https://docs.google.com/document/d/1CWwyvE53s7huI0ABtJ5UUNef0VKWX8uC-88uo0N2pHs/edit).
When a project is configured to use Git LFS, it also [requires configuration of each client machine](https://docs.gitlab.com/ee/topics/git/lfs/) via `.gitconfig` settings. There is the possibility that some users will not correctly configure their clients, and then accidentally push large files to the git repo instead of LFS.
## Investigation
How can we make sure that users do not accidentally push large files to the git repo instead of Git LFS? Here are some potential paths:
* configure the project in a way that ensures all clients have the correct Git LFS settings
* prevent (incorrectly setup) clients from pushing large files to the git repo.
Some thoughts:
- [git hooks](https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks) stored on the repo
- [Server hooks](https://docs.gitlab.com/ee/administration/server_hooks.html)
- other?
Does the routing to Git LFS occur only based on file extension or can file size also be considered?
## Problem
- LFS is configured for a project and its `.gitattributes` file contains an LFS filter (like `*.lfs filter=lfs diff=lfs merge=lfs -text`)
- A user doesn't have LFS config in their `.gitconfig` and pushes a raw file to GitLab
- GitLab recognizes that a file with an extension from `.gitattributes` is fully pushed (instead of it being an LFS pointer) and acts accordingly
## Possible solutions
- We can simply reject such files by default but I'm not sure yet whether it's disruptive
- We can implement a push rule `Enforce Git LFS`. Then such files will be rejected if the push rule is enabled.
issue