繁体   English   中英

Git分支自动执行源代码

[英]Git branches automate with source code

我正在使用Shell脚本在项目中自动执行git brnach。 代码说明

  • 我要去源目录
  • 我正在进行远程更新
  • 我要求用户输入分支,如果用户输入了错误的分支名称
  • 如果分支不存在,请捕获错误并向用户显示,否则git checkout并从分支中提取代码

    *

      #!/bin/bash cd application/src/ git remote update echo "please check all the available branch in git" git branch echo "Please enter the branch name: " read branch_name echo "You entered: $branch_name" branch=$(git branch) files=(branch*) select SEL in "${files[@]}" do if [[ "$SEL" ] !== '(no branch)'] then echo "Choose one of the available branch." break else git checkout $branch_name git pull origin $branch_name done git checkout $branch_name git branch git pull origin $branch_name* 

而且我得到这个错误。

Please enter the branch name:
1.5
You entered: 1.5
ram: line 21: conditional binary operator expected
ram: line 21: syntax error near `]'
ram: line 21: `    if  [[ "$SEL" ] !== '(no branch)']'

有人可以帮忙吗..

你为什么把[ ]放在$SEL周围。 将其重写为:

if  [ "$SEL" !== '(no branch)']'

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM