-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclone-repo.sh
41 lines (37 loc) · 1.02 KB
/
clone-repo.sh
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
#!/bin/bash
#
# Description: Clone a GitHub repository in your PC
#
# Require: git, gh
#
# Use: sh clone-repo.sh <org>
#
if [ $# -ne 1 ]; then
echo "Use: \n\t $0 <Organization>\n"
exit 1
fi
ORG=$1
clone() {
RUTA=$1
DEFUSER="git@github.com:"
DEFEXT=".git"
REPO="${DEFUSER}$RUTA${DEFEXT}"
echo "> git clone $REPO"
git clone $REPO
DIRECTORY=$(echo $RUTA | awk -F/ '{print $2}')
cd $DIRECTORY
git config pull.rebase false
git branch -r | grep -v '\->' | while read remote; do
git branch --track "${remote#origin/}" "$remote"
done
git fetch --all
git pull --all
cd ..
}
for repo in $(gh repo list ${ORG} -L 1000 | awk '{print $1}'); do
echo "-----------------------------------------------------------"
echo $repo
echo "-----------------------------------------------------------"
clone "$repo"
echo "-----------------------------------------------------------"
done