'Git commit issue after updating Mac OS

I am getting the below commit error in my Mac OS after updating to the latest version. Tried restarting VS Code and also tried to use terminal and same error. Until git add . step it works fine. Only the commit command is not working fine. What could be the issue?

enter image description here

 git commit -m "Commit message"
.git/hooks/pre-commit: line 15: python: command not found
.git/hooks/pre-commit: line 16: python: command not found


Solution 1:[1]

I found the issue. I removed the pre-commit file from the .git directory and that fixed the issue.

Solution 2:[2]

The MacOs 12.3 update removed the built-in python 2.7 client.

Options:

  • install python 2.7 manually, for example from here
  • look into the pre-commit file: maybe it can be updated to use python3 (which would need to be installed then of course)

Solution 3:[3]

The following code in the .git/hooks/pre-commit file throws python: command not found

else
  # Linux / Mac
  python ${HOOKS_DIR}/detect_remote
  python ${HOOKS_DIR}/detect_secret
fi%  

The solution for me is as easy as update python to python3 in the pre-commit file since I have python3 installed on my Mac.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Krishnamurthy
Solution 2 GhostCat
Solution 3 BabyPanda