Skip to content

Commit 197a4cf

Browse files
committed
Testing if branch already exists
1 parent b13be12 commit 197a4cf

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

git/branch_create.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,15 @@ then
2222
fi;
2323
fi;
2424

25-
git checkout "$BRANCH"
26-
git pull
27-
git checkout -b "$1"
25+
if [[ $(git branch | grep "$1" | wc -l) = "0" ]];
26+
then
27+
git checkout "$BRANCH"
28+
git pull
29+
git checkout -b "$1"
30+
else
31+
echo -e "$COLOR_RED"Moving to existing git branch."$COLOR_WHITE"
32+
git checkout "$1"
33+
fi;
2834
else
2935
echo -e "$COLOR_RED"Please, specify name of new branch."$COLOR_WHITE"
3036
show_syntax

0 commit comments

Comments
 (0)