I need to clone git branch into my local directory using a shell script.
#!/bin/sh
echo $0
full_path=$(realpath $0)
dir_path=$(dirname $full_path)
root_dir=$(dirname $dir_path )
REPO_DIR="${root_dir}/utils"
username="test1"
password="testpass"
BRANCH_NAME="test-cd"
GIT_URL="https://wwwin-example.com/internal/demo.git"
GIT=`which git`
cd ${REPO_DIR}
${GIT} clone -b ${BRANCH_NAME} ${GIT_URL}
Here I am doing clone one branch my directory but here I need to use username and password
along with the git command so that user will not provide it later. Once this script will run then the git clone
command with username and password will fetch the branch to my local directory.