-
Notifications
You must be signed in to change notification settings - Fork 0
/
initialize.sh
66 lines (57 loc) · 1.43 KB
/
initialize.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
66
#!/bin/bash
#
# Shell script for initialize any project with new Git repository.
#
# Notes:
# - Git repository on GitHub, Bitbucket or Gitlab is assumed.
# - Git is assumed.
# - Node is assumed.
# - NPM is assumed.
# - Unix environment, WSL 2 with Ubuntu or Cygwin app is assumed.
#
# I recommend SSH connection. Example: [email protected]:jjpeleato/slides-starter-boilerplate.git
GIT="~"
# Check Git uri is not empty.
if [ "$GIT" = "~" ] ; then
echo
echo "Sorry! Git url is empty. Stop initialize."
exit
fi
# Answer to continue
echo
echo "Warning! check the variable GIT if it is correct before continue."
echo "Do you want to initialize other Git project?. (y/n): "
read -r answer
if [ "$answer" != "${answer#[Yy]}" ] ; then
echo
echo "Sure! Cross your fingers and continue."
sleep 1
else
echo
echo "Good bye! Stop initialize."
exit
fi
# Remove .git/ directory.
echo
echo "Remove old git repository."
rm -rf .git/
# Start new Git repository and push first commit.
echo
echo "Start new Git repository."
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin "$GIT"
git push -u origin main
# Create develop branch and push all files.
echo
echo "Create develop branch and add all the code."
git checkout -b develop
git add .
git commit -m "feat: add all skeleton project files to the repository"
git push -u origin develop
# Finish
echo
echo "Finished! Initialize Git successfully."
exit