1

I am trying to commit a couple of files using git bash on windows 10. After doing git add, the file get staged and appear in green. Next when I run git commit , there is below message and nothing happens

"Python was not found but can be installed from the Microsoft Store: ms-windows-store://pdp/?productid=9NJ46SX7X90P"

I checked the python version by running python --version is git bash and it displays Python 2.7.2

Can someone please help me fix the issue with git commit ?

Akarsh KA
  • 11
  • 3
  • 'get staged and appear in green' you're clearly using some git frontend. What program is it? plain old `git bash` won't show anything if you type `git add xyz`, and AFAIK doesn't call python to do any commiting. Also, you're on windows I assume? That needs to be in the question too :) – 2e0byo Sep 24 '21 at 15:35
  • 5
    I strongly suspect you have a `.git/hooks/pre-commit` hook which tries to fire a python script and targets a version of python which is not installed in your environment. – Zeitounator Sep 24 '21 at 15:38
  • yes I am using git bash on windows 10. when I run git add , the file is getting staged. let me update the question. thanks for pointing out. let me know if something else is missing ? @2e0byo – Akarsh KA Sep 24 '21 at 15:42
  • could you add *exactly* what you typed into the shell? But I suspect @Zeitounator is right What is in `.git/hooks` ? – 2e0byo Sep 24 '21 at 15:56
  • this is the sequence of commands git status git add file1 file2 git commit file1 -m "comment" >> get the mentioned warning here... @2e0byo this is what is there in .git/hooks : couple of folders : "bouncera" and "checks" these files : commit-msg , post-checkout, post-commit, post-merge, pre-commit, pre-push one script : update_hooks.py – Akarsh KA Sep 24 '21 at 16:04
  • 1
    Clearly, your pre-commit hooks are not installed correctly. You can bypass them with `git commit -n`, but ideally you should find out from your team how your pre-commit hooks are supposed to be enabled. – joanis Sep 24 '21 at 16:19
  • @Zeitounator Is there a way to find out which version the hook is trying to invoke? I just tried with python 3.7 (earlier it was 2.7) by updating my PATH but still I get same warning. Is there a python dependency only with git commit ? because I don't get this warning with other commands like git add – Akarsh KA Sep 24 '21 at 16:21
  • @joanis sure, let me check – Akarsh KA Sep 24 '21 at 16:24
  • 2
    The pre commit hooks are scripts, you should be able to inspect them and see what they call. And you only see the problem with commit because other commands don't invoke the pre commit hooks. – joanis Sep 24 '21 at 17:07

1 Answers1

0

You can figure out if it is caused by a git hook using the following command:

strace git commit | grep access

If the reason for the error is a git hook, in the output, you'll be able to see that last accessed file like .git/hooks/pre-commit.

Shubham Chaudhary
  • 47,722
  • 9
  • 78
  • 80