File: grmbr.sh

package info (click to toggle)
ossim 2.9.1-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 29,740 kB
  • sloc: cpp: 383,170; ansic: 15,201; sh: 2,311; lex: 183; xml: 141; sql: 78; makefile: 77; csh: 6
file content (36 lines) | stat: -rwxr-xr-x 848 bytes parent folder | download | duplicates (2)
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
#!/bin/bash

#----------------------------------------------------------------------------------
# Git remove branch. Deletes local AND upstream origin/branch.
#----------------------------------------------------------------------------------

if [ -z $1 ]; then
  echo; echo "git remove branch: need branch name."; echo
  exit 0
fi 

branchname=$1
echo 
read -p "Are you sure you want to completely delete $branchname? [y/N]" yesno
if [ -z $yesno ]; then
  yesno="no"
fi

if [ $yesno == "y" ] || [ $yesno == "Y" ]; then
  git branch -d $branchname
  if [ $? -ne 0 ]; then
    echo; echo "Local branch not deleted."; echo
    exit 1
  fi
  git push origin --delete $branchname
  if [ $? -ne 0 ]; then
    echo; echo "Remote branch not deleted."; echo
    exit 1
  fi
fi

echo; echo "Branch $branchname successfully removed."; echo
exit 0