File tree 2 files changed +64
-0
lines changed 2 files changed +64
-0
lines changed Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # ----------------------------------------------------------------------------------
4
+ # Git create branch. Also creates upstream origin/branch and switches to new branch
5
+ # ----------------------------------------------------------------------------------
6
+
7
+ if [ -z $1 ]; then
8
+ echo ; echo " git remove branch: need branch name." ; echo
9
+ exit 0
10
+ fi
11
+
12
+ branchname=$1
13
+ git checkout -b $branchname
14
+ if [ $? -ne 0 ]; then
15
+ echo ; echo " Local branch not created." ; echo
16
+ exit 1
17
+ fi
18
+ git push -u origin $branchname
19
+ if [ $? -ne 0 ]; then
20
+ echo ; echo " Remote branch not created." ; echo
21
+ exit 1
22
+ fi
23
+ echo ; echo " Branch $branchname successfully created." ; echo
24
+
25
+ exit 0
26
+
27
+
28
+
Original file line number Diff line number Diff line change
1
+ #! /bin/bash
2
+
3
+ # ----------------------------------------------------------------------------------
4
+ # Git remove branch. Deletes local AND upstream origin/branch.
5
+ # ----------------------------------------------------------------------------------
6
+
7
+ if [ -z $1 ]; then
8
+ echo ; echo " git remove branch: need branch name." ; echo
9
+ exit 0
10
+ fi
11
+
12
+ branchname=$1
13
+ echo
14
+ read -p " Are you sure you want to completely delete $branchname ? [y/N]" yesno
15
+ if [ -z $yesno ]; then
16
+ yesno=" no"
17
+ fi
18
+
19
+ if [ $yesno == " y" ] || [ $yesno == " Y" ]; then
20
+ git branch -d $branchname
21
+ if [ $? -ne 0 ]; then
22
+ echo ; echo " Local branch not deleted." ; echo
23
+ exit 1
24
+ fi
25
+ git push origin --delete $branchname
26
+ if [ $? -ne 0 ]; then
27
+ echo ; echo " Remote branch not deleted." ; echo
28
+ exit 1
29
+ fi
30
+ fi
31
+
32
+ echo ; echo " Branch $branchname successfully removed." ; echo
33
+ exit 0
34
+
35
+
36
+
You can’t perform that action at this time.
0 commit comments