Automation for duplicate check

We are working an automation for duplicate check while committing in git, we are able to list duplicate files with a command in git, but we need to restrict committing duplicate files. If it is already done can you ping the solution.