-
Notifications
You must be signed in to change notification settings - Fork 0
/
git_repos.sh
executable file
·65 lines (44 loc) · 1.42 KB
/
git_repos.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
# Create github repos programmatically
# shellcheck source=/dev/null
source "$GLOBAL_PATH"/repos/oh_my_bash/custom.sh
unset GITHUB_TOKEN
gh --version || {
printColors red "Github CLI is not installed https://github.com/cli/cli#installation"
exit 1
}
if [ -z "$1" ]; then
printColors red "Repository name must exist"
exit 1
fi
mkdir "$GLOBAL_PATH/repos/$1"
cd "$GLOBAL_PATH/repos/$1" || exit
git init
printColors green "Updating git name and email"
git config user.email "byverdu@gmail.com"
git config user.name "Albert Vallverdu"
# allow git to push to the current branch even if it is not tracking any branch
git config --global --add --bool push.autoSetupRemote true
cat .git/config
printColors green "Creating repo at GitHub"
# create a repository with a specific name
# gh repo create $1
# -d, --description string Description of repository
# --public Make the new repository public
printColors green "Creating repo files"
echo "# $1" >>README.md
echo -e "node_modules
yarn-error.log
.DS_Store
.vscode
/dist
/coverage
.env" >>.gitignore
npm init --yes
git add .
git commit -m "initial repo setup"
gh repo create "$1" -d "$1 description" --public || { printColors red "Creating $1 failed"; }
git branch -M master
git remote add origin git@git.luolix.top-byverdu:byverdu/"$1".git # "-byverdu:" is used so we can have 2 git accounts in the same computer
git push -u origin master
printColors green "All done :)"