Warm tip: This article is reproduced from serverfault.com, please click

其他-如何在不创建本地存储库的情况下在Azure自托管代理和Powershell上进行git clone

(其他 - How to git clone on Azure self hosted agent and powershell without creating a local repo)

发布于 2020-11-27 17:10:08

我是Git的新手,需要帮助。在Azure管道上工作时,我创建了几个PowerShell脚本,这些脚本托管在Azure文件git repo中。当管道启动时,在Windows自托管代理上,我希望PowerShell脚本在git repo中下载脚本的最新版本。

我试过:

E:
CD myFolder
git clone --no-checkout https://token@acme.visualstudio.com/DefaultCollection/Project/_gits/fileRepos

但它只会创建_git文件夹和一个空结构

The fileRepos is structured like this: 
- fileRepos
  - Scripts
    - File 1
    - File 2

我不想创建本地存储库或跟踪文件,我只想下载文件。另外,对于我的代理,我需要以下结构:

e:\myFolder
  - Scripts
    - File 1
    - File 2

请你帮助我好吗?谢谢

Questioner
ClaudeVernier
Viewed
11
Leo Liu-MSFT 2020-11-30 14:10:30

如何在不创建本地存储库的情况下在Azure自托管代理和Powershell上进行git clone

我们可以在管道中添加复制任务,以fileRepos使用以下git clone命令删除文件夹:

D:

cd myFolderTemp

git clone https://PAT@dev.azure.com/<YourOrganizationName>/<YourProject>/_git/TestSample

然后添加复制任务以将文件从temp文件夹复制myFolderTempmyFolder不包含该.git文件夹的位置:

在此处输入图片说明