1

When using subprocess.call("git sparse-checkout") to execute a git command it returns an error saying that the git command doesn't exist:

git: 'sparse-checkout' is not a git command. See 'git --help'.

When running the same command in the terminal, however, I am able to use sparse-checkout with no problems.

I have also tried to use the following:

subprocess.call(['git', 'sparse-checkout'])
subprocess.call("git sparse-checkout", shell=True)
os.system("git sparse-checkout")

All return the same result.

I am using git 2.26.2 and Python 3.2 on RHEL 6.6

asked Jul 30, 2020 at 16:36

1 Answer 1

1

The error you are getting about 'sparce-checkout' is not a git command points to the version of git the script is initializing is not >= git 2.26.

It looks like this is a relatively new command with git. Two things I would do:

  1. Verify the version of git the script is initializing and what you see in the terminal
    subprocess.call(["which", "git"])
    subprocess.call(["git", "--version"])
    
  2. If there are multiple versions of git use the full path to the binary
answered Jul 30, 2020 at 17:11
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.