I am trying to clone a git repository hosted on Azure DevOps from within a notebook, using GitPython library. I generated a Personal Access Token with read/write access on git repositories.
The intent is to keep the git repository into the DBFS because it will be populated not only with notebooks sources but also outputs and MLFlow models.
In order to do so, I tried the following but keep facing error 128 from Git:
from git import Repo
git_url = 'https://<myPAT>@dev.azure.com/<org>/<project>/_git/<repo>'
repo = Repo.clone_from(git_url, '/git/')
Always resulting in the error, witout more details:
GitCommandError: Cmd('git') failed due to: exit code(128)
I checked from other places, my PAT is working perfectly.
I also tried to encode the PAT in Base64 and add the header 'Authorization : Basic <base64PAT>'
using the command below, but the result is the same.
encodedBytes= base64.urlsafe_b64encode(PAT.encode("utf-8"))
base64PAT= str(encodedBytes, "utf-8")
header = 'Authorization : Basic ' + base64PAT
git.Git().config_writer().set_value("http", "extraHeader", header).release()
Any hint on this ? Is GitPython relying on another config that I need to update or should I use another method ?
GitCommandError: Cmd('git') failed due to: exit code(128)
Based on your description, your PAT has enough permission to clone the repo.
So this issue is not related with PAT.
The root cause of this issue should be that the target path('/git/'
) already exists and is not an empty directory.
To solve this issue, you need to specify a folder that does not exist in the path. Then the script will create a new folder and clone the repo to the New folder.
Here is my sample:
from git import Repo
full_local_path = "C:\kevin1234"
remote = f"https://PAT@dev.azure.com/{Org]/{Project}/_git/{repo}"
Repo.clone_from(remote, full_local_path)
Result: