Skip to content

Commit f19a687

Browse files
committed
testing
1 parent e847ec0 commit f19a687

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

make_ssh.sh

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
#/bin/bash
2+
#-- Script to automate https://help.github.com/articles/why-is-git-always-asking-for-my-password
3+
4+
REPO_URL=`git remote -v | grep -m1 '^origin' | sed -Ene's#.*(https://[^[:space:]]*).*#\1#p'`
5+
if [ -z "$REPO_URL" ]; then
6+
echo "-- ERROR: Could not identify Repo url."
7+
echo " It is possible this repo is already using SSH instead of HTTPS."
8+
exit
9+
fi
10+
11+
USER=`echo $REPO_URL | sed -Ene's#https://github.com/([^/]*)/(.*).git#\1#p'`
12+
if [ -z "$USER" ]; then
13+
echo "-- ERROR: Could not identify User."
14+
exit
15+
fi
16+
17+
REPO=`echo $REPO_URL | sed -Ene's#https://github.com/([^/]*)/(.*).git#\2#p'`
18+
if [ -z "$REPO" ]; then
19+
echo "-- ERROR: Could not identify Repo."
20+
exit
21+
fi
22+
23+
NEW_URL="[email protected]:$USER/$REPO.git"
24+
echo "Changing repo url from "
25+
echo " '$REPO_URL'"
26+
echo " to "
27+
echo " '$NEW_URL'"
28+
echo ""
29+
30+
CHANGE_CMD="git remote set-url origin $NEW_URL"
31+
`$CHANGE_CMD`
32+
33+
echo "Success"

0 commit comments

Comments
 (0)