1
votes

I have this script which clones azure repo.

I am trying to execute git push command in it.It gives me error - fatal: not a git repository (or any of the parent directories): .git Error in pushing to AZ repo: Command 'git push https://[email protected]/xxx/yyy.git' returned non-zero exit status 128

import subprocess

def subprocess_exec(state, cmd):
    try:
        subprocess.check_output(cmd, shell=True)
        return "Success"
    except subprocess.CalledProcessError as merror:
        print("Error in {}: {}".format(state, merror))

az_repo_cmd = 'git -c http.extraHeader="Authorization: Basic ' + 
'PAT' + '" ' +  'clone    
https://dev.azure.com/' + 'ORG_Name' + '/' + 'Project_Name' + '/_git/'   
+ "Repo_Name"
if subprocess_exec("Cloning from AZ repo", az_repo_cmd) == "Success":
print("Done")

az_repo_cmd2 = 'git push   
https://[email protected]/xxx/yyy.git'
subprocess_exec("pushing to AZ repo", az_repo_cmd2)

How can I use git push , git create branch etc. git commands for Azure repos using script ?

developer.github.com/changes/… TLDR: Basic Authentication no longer is allowed - Ryan Schaefer
I tried this command as shown in document - git push 'Authorization: token XXXXX' dev.azure.com{org}/{project}/_git/{repo} This still gives me wrong ref error. Not sure what's the right command for pushing to azure repos using PAT token - megha
How did you run your python scripts? According to the error not a git repository, it seems we are not cd into the directory, would you please share your build definition configuration? - Leo Liu-MSFT