diff --git a/build_tools/make_version b/build_tools/make_version
index ce3bf6e130e685304a34583a2108e6ebf938f479..ad9fb3f92427e0e192fb0db2a881b985c834ee14 100755
--- a/build_tools/make_version
+++ b/build_tools/make_version
@@ -3,7 +3,6 @@
 AWK=${AWK:-awk}
 GIT=${GIT:-git}
 GREP=${GREP:-grep}
-MAINLINE_BRANCH=master
 
 if [ -f ${1}/.version ]; then
     cat ${1}/.version
@@ -101,6 +100,7 @@ elif [ -d ${1}/.git ]; then
     MODIFIED=""
     SVN_REV=`${GIT} log --pretty=full -1 | ${GREP} -F "git-svn-id:" | sed -e "s/.*\@\([^\s]*\)\s.*/\1/g"`
     if [ -z "$SVN_REV" ]; then
+        MAINLINE_BRANCH=$(git config -f .gitreview --get gerrit.defaultbranch)
         VERSION=`${GIT} describe --long --always --tags --dirty=M 2> /dev/null`
         if [ $? -ne 0 ]; then
             if [ "`${GIT} ls-files -m | wc -l`" != "0" ]; then