我在 Azure DevOps 中有一个存储库,我需要克隆并运行一些 python 代码,然后将结果推回到同一个存储库中。
随着时间的推移,提交历史记录/对象变得越来越大,每次运行所需的时间也越来越长。它看起来像使用 fetchDepth
进行浅克隆可能是最好的选择,但缺乏在 ADO 中实现它的信息,因为它找不到“master”分支。
我收到以下错误:error: pathspec 'master' did not match any file(s) known to git.
和error: src refspec master does not match any.
.
似乎找不到master,我该如何解决这个问题或者我还可以尝试什么?
azure-pipeline.yml
jobs:
- job: Default
timeoutInMinutes: 60
pool:
name: XXX
workspace:
clean: all
steps:
- task: DeleteFiles@1
inputs:
SourceFolder:
Contents: '*'
- checkout: self
persistCredentials: false
clean: true
displayName: Checkout and clean
fetchDepth: 3 #Shallow clone
- task: CmdLine@2
inputs:
script: |
uname -a
python3 --version
pip3 install -r requirements.txt
echo check system
git clean -d -f
pwd
ls -l
- task: CmdLine@2
inputs:
script: |
echo "Running code"
python3 some_script.py
git config --global user.email "XXX.com"
git config --global user.name "XXX"
git add ../csv/
git commit -m 'updated files'
git push https://XXX:$(PAT)@XXX.visualstudio.com/XXX master
最佳答案
--深度
克隆操作仅下 pull 一个分支。如果远程存储库包含其他分支,他们将无法在没有路径规范错误的情况下在本地 check out 它们。
您需要显式克隆master
分支:
git clone --depth 3 --branch master https://dev.azure.com/test/test/_git/test
阅读here更多信息。
关于git - 如何使用 Azure DevOps 推送到浅克隆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76036110/