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/hexgen/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..


Source: bash

Leave a Reply