bash - Git branches automate with source code -
i automating git brnach project using shell script. code description
- i going source directory
- i doing remote update
- i asking user enter branch, if user entered wrong branch name
if branch doest not exist catch error , show user otherwise git checkout , pull code branch
*
#!/bin/bash cd application/src/ git remote update echo "please check available branch in git" git branch echo "please enter branch name: " read branch_name echo "you entered: $branch_name" branch=$(git branch) files=(branch*) select sel in "${files[@]}" if [[ "$sel" ] !== '(no branch)'] echo "choose 1 of 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 getting error.
please enter branch name: 1.5 entered: 1.5 ram: line 21: conditional binary operator expected ram: line 21: syntax error near `]' ram: line 21: ` if [[ "$sel" ] !== '(no branch)']'
can this..
why did put [ ]
around $sel
. rewrite as:
if [ "$sel" !== '(no branch)']'
Comments
Post a Comment