2016-11-29 20 views
0

我目前正在获取名为Devops的GitHub项目的存储库,并且它正在获取主数据。但现在我想获得分支,而不是默认获取的主分支,但我不知道如何从powershell脚本执行它。这是如何完成主分支。如何使用powershell脚本任务调用一个竹分支而不是主从GitHub

cd ${bamboo.build.working.directory} 
if [ -d devops ] ; then 
cd devops 2>/dev/null && git pull || git clone https://MYGIT:[email protected]/myRepo/devops 
else 
git clone https://MYGIT:[email protected]/myRepo/devops 
fi 

我试图.branchname,/ BRANCHNAME,-branchname等添加到它的结束,但它没有找到分支,我怎么能找到的分支,而不是大师?

回答

1

我做这个得到了答案:

git clone -b BRANCH_NAME https://MYGIT:[email protected]/myRepo/devops 

的其他部分,然后在if语句我这样做:

# Get the current branch 
function gitBranchName { 
    $currentBranch = "master" 
    git branch | foreach { 
     if ($_ -match "<branch_name>") { 
      $currentBranch = "<branch_name>" 
     } 
    } 
    return $currentBranch 
} 
相关问题