-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove_topic_branch
More file actions
executable file
·39 lines (33 loc) · 1.07 KB
/
remove_topic_branch
File metadata and controls
executable file
·39 lines (33 loc) · 1.07 KB
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
#!/usr/bin/env bash
#
############################################################################
#
# Name: remove_topic_branch
# Author: Manik Surtani (http://github.com/maniksurtani)
# Description: This script removes a topic branch - both locally as well as
# on the origin.
#
# Configuration: The following variables need to be set.
ORIGIN_REPO="origin" # The fork of upstream. Can be a named remote or a full URL.
GIT="git" # Path to the git binary executable
#
############################################################################
if [ ! -d ".git" ] ; then
echo "This script MUST be run in the local clone of your forked repo"
exit
fi
if [ -z $1 ] ; then
echo "Usage: remove_topic_branch <name of topic branch to remove>"
exit
fi
CURRENT_BRANCH=`git symbolic-ref --short HEAD`
while [ ! -z $1 ] ; do
BRANCH=$1
if [ "$BRANCH" == "$CURRENT_BRANCH" ] ; then
$GIT checkout $(find_upstream_branch)
fi
$GIT branch -D $BRANCH
$GIT push -q -f $ORIGIN_REPO :${BRANCH}
echo "Topic branch $BRANCH removed both locally and on $ORIGIN_REPO"
shift
done