diff --git a/sh/git-branch-clean.sh b/sh/git-branch-clean.sh new file mode 100755 index 0000000..c1cfd8b --- /dev/null +++ b/sh/git-branch-clean.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +echo "=========================================================================" +echo "This script will check if master branch contains commit from this branch." +echo "Then suggest if the branch can be deleted" +echo "=========================================================================" +echo "" + +CURRBRANCH=$(git branch --show-current) +COMMITID=$(git rev-parse HEAD) +git switch -q master +git log | grep $COMMITID +if [ $? -eq 1 ]; then + echo "commit not found in master. You should keep $CURRBRANCH" +else + echo "commit found in master. You should delete $CURRBRANCH" + git log -n1 $COMMITID +fi +git switch -q $CURRBRANCH