我使用shell脚本使用我的项目自动执行git brnach。代码说明
如果分支doest不存在捕获错误并显示用户,否则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)']'
有人可以帮忙..
答案 0 :(得分:0)
为什么要将[ ]
放在$SEL
附近。将其改写为:
if [ "$SEL" !== '(no branch)']'