Skip to content

Instantly share code, notes, and snippets.

@ronisaha
Last active August 29, 2015 14:05
Show Gist options
  • Save ronisaha/ea130f5643cc5af3c760 to your computer and use it in GitHub Desktop.
Save ronisaha/ea130f5643cc5af3c760 to your computer and use it in GitHub Desktop.
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..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment