user3868051
user3868051

Reputation: 1259

azure devops git error: 'fatal: 'testpr' does not appear to be a git repository, Could not read from remote.' when using git-request-pull in devops

I am running the following:

git checkout -b testpr
touch test.txt
git add .
git commit -m "minor update"
git push --set-upstream origin testpr
    Enumerating objects: 19, done.
    Counting objects: 100% (19/19), done.
    Delta compression using up to 8 threads
    Compressing objects: 100% (10/10), done.
    Writing objects: 100% (11/11), 1.24 KiB | 30.00 KiB/s, done.
    Total 11 (delta 6), reused 0 (delta 0), pack-reused 0
    remote: Analyzing objects... (11/11) (7 ms)
    remote: Checking for credentials and other secrets... (3/3) done (24 ms)
    remote: Checking for reserved names in refs, blobs and trees...  done (24 ms)
    remote: Storing packfile... done (67 ms)
    remote: Storing index... done (97 ms)
    To https://org.visualstudio.com/DefaultCollection/projectname/_git/reponame
     * [new branch]        testpr -> testpr
    Branch 'testpr' set up to track remote branch 'testpr' from 'origin'.

now in order to create PR I have tried:

  1. git request-pull origin/master testpr
  2. git request-pull origin/master origin/testpr

both give error:

fatal: 'testpr' does not appear to be a git repository
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
warn: Are you sure you pushed 'HEAD' there?

Could anyone help me find a way around this? Thanks!

Upvotes: 0

Views: 431

Answers (1)

Yan Sklyarenko
Yan Sklyarenko

Reputation: 32270

According to the documentation of the git request-pull command, the second parameter must be the URL of the repository. Thus, the correct syntax for your case will be the following:

git request-pull master https://org.visualstudio.com/DefaultCollection/projectname/_git/reponame testpr

Note that you don't have to prefix the branches with origin/ because the command operates with the remote branches anyway.

However, this command will only print the request to the output. It won't create an Azure DevOps PR for you. Read this part of the command description carefully:

Generate a request asking your upstream project to pull changes into their tree. The request, printed to the standard output, begins with the branch description, summarizes the changes and indicates from where they can be pulled.

In order to create a true PR in Azure DevOps programmatically, you can either use the REST API or try the Azure DevOps CLI.

Upvotes: 1

Related Questions