【问题标题】: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天蓝色 devops git 错误:'致命:'testpr' 似乎不是 git 存储库,无法从远程读取。'在 devops 中使用 git-request-pull 时
【发布时间】:2021-08-05 06:11:26
【问题描述】:

我正在运行以下命令:

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'.

现在为了创建 PR,我已经尝试过:

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

都报错:

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?

谁能帮我找到解决这个问题的方法? 谢谢!

【问题讨论】:

  • git request-pull 不是要使用的命令。拉取请求——这是一种网络托管站点功能——不应与git request-pull 混淆,后者不会发出(这类)拉取请求。

标签: git github azure-devops devops


【解决方案1】:

根据documentation of the git request-pull command,第二个参数必须是仓库的URL。因此,您的案例的正确语法如下:

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

请注意,您不必为分支添加前缀origin/,因为该命令无论如何都会对远程分支进行操作。

但是,此命令只会将请求打印到输出。它不会为您创建 Azure DevOps PR。仔细阅读这部分命令说明:

生成一个请求,要求您的上游项目将更改拉入 他们的树。 打印到标准输出的请求以 分支描述,总结变化并指出从 可以拉到哪里。

要以编程方式在 Azure DevOps 中创建真正的 PR,您可以使用 the REST API 或尝试 the Azure DevOps CLI

【讨论】:

  • 感谢@Yan 的帮助,但是我收到上面一行的错误消息:fatal: Not a valid revision: master
  • 我正在使用git version 2.30.2.windows.1 fyi
  • 你的仓库有master 分支吗?您的本地master 是否指向与远程相同的版本?您也可以尝试指定确切的提交哈希而不是分支名称
猜你喜欢
  • 2015-11-21
  • 1970-01-01
  • 1970-01-01
  • 2020-01-20
  • 2015-01-25
  • 1970-01-01
  • 2015-07-01
  • 2012-11-10
  • 2015-01-19
相关资源
最近更新 更多