我正在开发Azure DevOps项目中的存储库,该存储库是从其他一些Azure Azure DevOps项目派生的。我想知道来源(进行分叉的原始存储库)。
让我知道如何获取此信息。
我不知道这在UI中公开,但是至少还有另外两种方法可以获取有关上游(父)存储库的信息
甲GET
请求https://dev.azure.com/{organization}}/{{project}}/_apis/git/repositories/{{forkname}}?includeParent=true&api-version=6.0
将具有称为字段parentRepository
在含有约上游储存库的细节返回消息
...
"parentRepository": {
"id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"name": "myrepo",
"isFork": false,
"url": "https://dev.azure.com/myorg/_apis/git/repositories/xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
"remoteUrl": "https://[email protected]/myorg/myproject/_git/myproject",
"sshUrl": "[email protected]:v3/myorg/myproject/myproject",
"project": {
"id": "yyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy",
"name": "myproject",
"url": "https://dev.azure.com/myorg/_apis/projects/zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz",
"state": "unchanged",
"visibility": "unchanged",
"lastUpdateTime": "0001-01-01T00:00:00"
},
"collection": null
}
...
从Azure DevOps仓库克隆分叉的仓库时,服务器会发送以下消息(在标准git命令行客户端中可见)
Cloning into 'myfork'...
Password for 'https://[email protected]':
remote: Azure Repos
remote: This repository is a fork. Learn more at https://aka.ms/whatisafork.
remote: To add its upstream as a remote, run:
remote: git remote add upstream https://[email protected]/myorg/myproject/_git/myrepo
remote:
remote: Found 9 objects to send. (67 ms)
Unpacking objects: 100% (9/9), 1.78 KiB | 6.00 KiB/s, done.
从此消息中,您可以通过查看建议的上游遥控器找到原始存储库:
git remote add upstream https://[email protected]/myorg/myproject/_git/myrepo
换句话说,fork的上游仓库被调用myrepo
并位于myproject
inside myorganization
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句