blob: 709ead0192cdd47c719989e9fcb068174526db4c (
plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
|
#!/bin/bash
# this is to be run locally after remote script has executed
if [ $# -ne 1 ]; then
echo -e "\nUsage: $0 'new-repo-name'\n"
exit 1
fi
if [ -d "$1" ]; then
echo "Directory $1 already exists. Aborting."
exit 1
fi
echo -e "\nCreating new repo $PWD/$1"
mkdir "$1" && echo "created $PWD/$1"
cd "$1"
git init && echo "initialized $1"
touch README.md && echo "created 'README.md'"
echo "init" > README.md
git add . && echo "staged $1"
git commit -m 'initial commit' && echo "commited repo"
echo -e "\n\n"
while true; do
echo "Enter remote name and URL (press enter to finish)"
echo -e "eg. origin ssh://git@ssh.github.com:443/user/$1\n"
read -p ": " name url
if [ -z "$name" ] && [ -z "$url" ]; then
break
fi
if [ -z "$name" ] || [ -z "$url" ]; then
echo -e "\nYou must provide a name and url"
echo -e "eg. origin ssh://git@ssh.github.com:443/user/$1\n\n"
continue
fi
git remote add "$name" "$url"
echo "added $name ($url)"
done
read -p "Push to remote? (y/n): " push_choice
if [[ "$push_choice" =~ ^[Yy]$ ]]; then
for remote in $(git remote); do
git push "$remote" --all
echo "Pushed to remote: $remote"
done
else
echo "Push aborted."
fi
cd ..
|