I added git config --global --add safe.directory '*'
right before running the pre-commit command and it worked. Thanks to the suggestion.
The pre-commit tool documentation does not have anything that relates to the error I originally received. Hopefully this solution will help others getting the same error in the future.