diff --git a/common-subtree.sh b/common-subtree.sh
index b757ed6115ca1f9e3ef9bb64d38df16f0018acbd..c99aa601b0498d823b88f6a9a5f76286207c65d5 100755
--- a/common-subtree.sh
+++ b/common-subtree.sh
@@ -8,7 +8,16 @@ usage () {
 }
 
 branch="$(git symbolic-ref --short HEAD)"
-test -z "$branch" && branch="master"
+case "$branch" in
+	apertis/*)
+		;;
+	*)
+        # take the default remote branch if we're not on a apertis/* branch
+		branch=$(git ls-remote --symref git@gitlab.apertis.org:tests/common.git HEAD \
+		         | grep ^ref: \
+		         | sed 's,ref: refs/heads/\(.*\)\s\+HEAD,\1,')
+		;;
+esac
 
 case $1 in
 pull)