Created
March 26, 2020 10:15
-
-
Save andgineer/91808c22cdb14a06cd0a517521f538d4 to your computer and use it in GitHub Desktop.
Adding credentials to GIT remote
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function gitcred () { | |
rep_uri=$(git config --get remote.origin.url) | |
rep_proto=${rep_uri:0:8} | |
rep_url=${rep_uri:8} | |
user_name=$1 | |
user_name=${user_name:-andgineer} | |
user_psw=$2 | |
user_psw=${user_psw:-???} | |
uri=$rep_proto$user_name:$user_psw@${rep_url#*@} | |
read -p "Set the URI $uri? [Y]" -n 1 -r | |
echo | |
if [[ $REPLY =~ ^[Yy]$ ]] | |
then echo "..setting" | |
git remote set-url origin $uri | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment