-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_batch_set_remotes.sh
More file actions
executable file
·45 lines (40 loc) · 1.2 KB
/
git_batch_set_remotes.sh
File metadata and controls
executable file
·45 lines (40 loc) · 1.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/bash
echo "--Start"
for d in */; do
echo "Checking $d"
cd $d
# Check if the current directory is a git directory
if git rev-parse --git-dir > /dev/null 2>&1
then
OLDREMOTE="$(git config --get remote.origin.url)"
if [[ $OLDREMOTE == http*bitbucket.org/vizucom* ]]
then
# Strip everything until /vizucom
OLDSUFFIX=${OLDREMOTE#*/vizucom}
# Replace the beginning
NEWREMOTE="git@bitbucket.org:vizucom${OLDSUFFIX}"
git remote set-url origin ${NEWREMOTE}
echo "-Updated remote to:" ${NEWREMOTE}
echo "-Old remote was: " ${OLDREMOTE}
elif [[ $OLDREMOTE == http*github.com/Vizucom* ]]
then
OLDSUFFIX=${OLDREMOTE#*/Vizucom}
NEWREMOTE="git@github.com:Vizucom${OLDSUFFIX}"
git remote set-url origin ${NEWREMOTE}
echo "-Updated remote to:" ${NEWREMOTE}
echo "-Old remote was: " ${OLDREMOTE}
else
if [[ $OLDREMOTE != *vizucom* ]] && [[ $OLDREMOTE != *Vizucom* ]]
then
echo "-Not a Vizucom Github/Bitbucket repository"
else
echo "-Already using SSH authentication"
fi
fi
else
echo "-Not a git repository"
fi
echo ""
cd ..
done
echo "--Done."