Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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?

 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
                As the output shows, you have pre-commit hooks that require python, and python is not installed or it's not on the path.
– Robby Cornelissen
                Mar 25, 2022 at 4:58

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

# Linux / Mac python ${HOOKS_DIR}/detect_remote python ${HOOKS_DIR}/detect_secret

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.

Note: this is not the issue, this is not a fix. This is just: ignoring the underlying problem. Commit hooks exist so that specific code gets executed prior you doing the commit. What happens here is that the latest MacOs update REMOVED python 2.7 (so the python binary you have in your path), and therefore that code cant be executed any more. So, the real answers could be: to change the commit hook code to use python3, or to manually install some python, ... plenty of options. Each one better than just removing that file. – GhostCat Mar 30, 2022 at 7:15 This is an actively harmful answer. Deleting the pre-commit file without knowing why it is there, and how it got there, encourages developers to make decisions in isolation that may negatively impact a project and its collaborators. – Patrick Johnmeyer Nov 18, 2022 at 17:30

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.