Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 如何将特定文件从Azure Repos复制到unix计算机_Git_Azure Devops_Wget_Azure Repos - Fatal编程技术网

Git 如何将特定文件从Azure Repos复制到unix计算机

Git 如何将特定文件从Azure Repos复制到unix计算机,git,azure-devops,wget,azure-repos,Git,Azure Devops,Wget,Azure Repos,我在Azure DevOps中有一个项目。我想将一个特定文件从项目的Git存储库复制到我的unix设备中。我想使用命令行实现这一点 我试过下面的命令 wget -O /unix/path/to/save/file.txt "https://tfs-glo-org.visualstudio.com/team/_git/projectName?path=/fileTobeCopied&version=GBbranch" 它成功地将一个文件复制到unix设备中,但它不仅保存了我想要的文件

我在Azure DevOps中有一个项目。我想将一个特定文件从项目的Git存储库复制到我的unix设备中。我想使用命令行实现这一点

我试过下面的命令

  wget -O /unix/path/to/save/file.txt "https://tfs-glo-org.visualstudio.com/team/_git/projectName?path=/fileTobeCopied&version=GBbranch"

它成功地将一个文件复制到unix设备中,但它不仅保存了我想要的文件,还保存了整个html页面。

这绝非易事。原始下载url稍微复杂一些:

 GET https://dev.azure.com/{organization}/{project}/_apis/git/repositories/{repositoryId}
     /items?path={path}&scopePath={scopePath}&recursionLevel={recursionLevel}
     &includeContentMetadata={includeContentMetadata}&latestProcessedChange={latestProcessedChange}
     &download={download}&$format={$format}&versionDescriptor.versionOptions={versionDescriptor.versionOptions}
     &versionDescriptor.version={versionDescriptor.version}&versionDescriptor.versionType={versionDescriptor.versionType}
     &includeContent={includeContent}&resolveLfs={resolveLfs}&api-version=5.1
这里最重要的是设置
&download=true
。获取这些值的最简单方法是从UI下载文件并检查下载url:

您可以从浏览器的下载页面获取完整url:

这个

为了下载成功,您还需要传入身份验证令牌或个人访问令牌。这个

最简单的选择:


如果未传入凭据,Azure DevOps将改为发送错误页内容。

文件存储在Git源代码管理中是有原因的。 不要以您尝试的方式下载

使用命令行
git clone
打开存储库并找到要拾取的文件


您始终可以针对特定的或。

更新的TFS->Azure Repos,因为您的示例URL引用
.visualstudio.com
。这可能只是我们的管理员设置,但我下载的是html文档,而不是我针对的.sh。这是您遇到过的问题吗?当您获得HTML时,很可能是访问被拒绝或未找到文件。我的猜测是,令牌没有正确的权限,已过期或不适用于正确的组织。
 wget --user . --password {PAT} https://dev.azure.com/....