ronisaha
9/2/2014 - 3:35 PM

Update git repository if your system does not ask for git password

Update git repository if your system does not ask for git password

#!/bin/bash

echo -n "Enter github Username: "
read USER_NAME

echo -n "Enter github repository name: "
read REPO_NAME

echo -n "Enter Password:"
read -s PASSWORD
echo

git checkout .

TEMP_REMOTE_NAME="temp$(date +%Y%m%d%H%m%s)"

{
    git remote add ${TEMP_REMOTE_NAME} "https://$USER_NAME:$PASSWORD@github.com/$REPO_NAME.git"
} || {
    echo 
}
{
    git pull ${TEMP_REMOTE_NAME} master
} || {
    echo "Unable to update code from git"
}

git remote remove ${TEMP_REMOTE_NAME}

echo "Operation completed..."