简体   繁体   中英

Git branches automate with source code

I am automating the git brnach with my project using shell script. 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

    *

      #!/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 . Rewrite it as:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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