-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup.sh
56 lines (44 loc) · 1.18 KB
/
setup.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
#!/bin/sh
if [ ! -f "update.txt" ]
then
remote_branch=$(git rev-parse --abbrev-ref @{u})
if [[ "$remote_branch" != "origin/"* ]]
then
echo "This script can only handle remotes named origin!"
exit -1
fi
remote_branch=${remote_branch#"origin/"}
repository_url=$(git remote get-url origin)
echo "$repository_url"
echo "$repository_url" >> update.txt
echo "$remote_branch" >> update.txt
fi
current_branch=$(git rev-parse --abbrev-ref HEAD)
branches_to_delete=$(git for-each-ref --format='%(refname:short)' refs/heads/)
for branch in $branches_to_delete
do
if [ "$branch" != "$current_branch" ]
then
git branch -d "$branch"
fi
done
if [ "$current_branch" != "develop" ]
then
git checkout -b develop
git branch -d "$current_branch"
fi
git remote remove origin
git add .
git commit -m "Initial commit"
git branch master
echo "Enter URL of the project's git repository (Leave empty to skip this step):"
read new_remote
if [ -n "$new_remote" ]
then
echo "Setting up repository..."
git remote add origin $new_remote
git push -u origin develop
git checkout master
git push -u origin master
fi
echo "Done!"