简体   繁体   English

Git分支自动执行源代码

[英]Git branches automate with source code

I am automating the git brnach with my project using shell script. 我正在使用Shell脚本在项目中自动执行git brnach。 Code Description 代码说明

  • I am going to the source directory 我要去源目录
  • I am doing remote update 我正在进行远程更新
  • I am asking user to enter the branch, if user entered wrong branch name 我要求用户输入分支,如果用户输入了错误的分支名称
  • If the branch doest not exist catch the error and show the user otherwise git checkout and pull the code from the branch 如果分支不存在,请捕获错误并向用户显示,否则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* 

And i am getting this error. 而且我得到这个错误。

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)']'

Can someone help this.. 有人可以帮忙吗..

Why did you put [ ] around $SEL . 你为什么把[ ]放在$SEL周围。 Rewrite it as: 将其重写为:

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

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

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