diff --git a/sette/all_functions.sh b/sette/all_functions.sh
index 326b38d1fb7069d5e6d4062dc87625b878d83a3e..d9f87067d7baef11909247a459e203179bcc5348 100755
--- a/sette/all_functions.sh
+++ b/sette/all_functions.sh
@@ -172,7 +172,8 @@ clean_config() {
 # define validation dir
 set_valid_dir () {
     if [ ${DETACHED_HEAD} == "no" ] ; then
-      REVISION_NB=`git -C ${MAIN_DIR} rev-list --abbrev-commit origin | head -1l`
+      branchname=$( git branch --show-current )
+      REVISION_NB=$( git -C ${MAIN_DIR} rev-list --abbrev-commit origin/$branchname | head -1l )
     else
       REVISION_NB=${DETACHED_CMIT}
     fi