diff --git a/create_documentation b/create_documentation
index d9b0b4161f4047f27e7721d68d8466e35ff6a5d2_Y3JlYXRlX2RvY3VtZW50YXRpb24=..63cf5d2ab703aa1aa239200c3042528935398fa7_Y3JlYXRlX2RvY3VtZW50YXRpb24= 100755
--- a/create_documentation
+++ b/create_documentation
@@ -38,8 +38,11 @@
 	    make -e SPHINXOPTS=-Dlanguage=${language} $format
 	    # TODO read value from Makefile
 	    builddir=_build
-	    # TODO read value from hg/git
-	    branch=default
+	    if [ -e ".git" ]; then
+		branch="$(git rev-parse --abbrev-ref HEAD)"
+	    elif [ -e ".hg" ]; then
+		branch="$(hg id -b)"
+	    fi
 	    dest_dir=$out_dir/$project_name/$language/$branch
 	    if [[ $? -eq 0 ]] ; then
 		echo "${YELLOW}INFO ${RESET} - Documentation generation done for $doc_dir (superproject), copy to $dest_dir"
@@ -68,8 +71,11 @@
     			make -e SPHINXOPTS=-Dlanguage=${language} $format
 			# TODO read value from Makefile
 			builddir=_build
-			# TODO read value from hg/git
-			branch=default
+			if [ -e ".git" ]; then
+			    branch="$(git rev-parse --abbrev-ref HEAD)"
+			elif [ -e ".hg" ]; then
+			    branch="$(hg id -b)"
+			fi
 			dest_dir=$out_dir/$module/$language/$branch
 			if [[ $? -eq 0 ]] ; then
 			    echo ${YELLOW}INFO ${RESET} - Documentation generation done for $dir/$module/$doc_dir, copy to $dest_dir