diff --git a/common-subtree.sh b/common-subtree.sh
index 59c5e21b3d73466f45e92bef5c038a13600c297f..b757ed6115ca1f9e3ef9bb64d38df16f0018acbd 100755
--- a/common-subtree.sh
+++ b/common-subtree.sh
@@ -7,12 +7,15 @@ usage () {
 	echo "'$0 pull' is used to update the common subtree in tests"
 }
 
+branch="$(git symbolic-ref --short HEAD)"
+test -z "$branch" && branch="master"
+
 case $1 in
 pull)
-git subtree pull -P common git@gitlab.apertis.org:tests/common.git master
+git subtree pull -P common git@gitlab.apertis.org:tests/common.git "$branch"
 ;;
 add)
-git subtree add -P common git@gitlab.apertis.org:tests/common.git master
+git subtree add -P common git@gitlab.apertis.org:tests/common.git "$branch"
 ;;
 *) usage;;
 esac