diff --git a/public_html/deployment/classes/project_gui.class.php b/public_html/deployment/classes/project_gui.class.php
index f341d9bc1e924b966eb18f84ceb1bd7946bc136d..de11b83d2598dfd5d299af5d0caccc22412479ba 100644
--- a/public_html/deployment/classes/project_gui.class.php
+++ b/public_html/deployment/classes/project_gui.class.php
@@ -935,7 +935,7 @@ class projectgui extends project {
         );
 
         // detect access to repo url
-        $aBranches=$this->getRemoteBranches();
+        $aBranches=$this->getRemoteBranches(true);
         // $aRepodata = $this->getRepoRevision();
 
         // if (is_array($aRepodata) && array_key_exists("message", $aRepodata)) {
diff --git a/public_html/deployment/classes/vcs.git.class.php b/public_html/deployment/classes/vcs.git.class.php
index 406aaf047fc6f4ba2bd2595ede24aa3bf962a100..93fd235d267aa49031603aba8323ebb95989bd8e 100644
--- a/public_html/deployment/classes/vcs.git.class.php
+++ b/public_html/deployment/classes/vcs.git.class.php
@@ -251,7 +251,8 @@ class vcs implements iVcs {
         $this->log(__FUNCTION__."(bIgnoreCache = ".($bIgnoreCache ? 'true' : 'false').") start");
         $aReturn = array();
 
-        if (!$this->getUrl()) {
+        $sGitUrl=$this->getUrl();
+        if (!$sGitUrl) {
             return false;
         }
 
@@ -265,18 +266,30 @@ class vcs implements iVcs {
             $sWorkdir = dirname($this->_sTempDir) . '/fetchRemoteBranches/';
             $this->log(__FUNCTION__." - sWorkdir = $sWorkdir");
             $sGitCmd = 'export GIT_SSH="' . $this->_sWrapper . '" ; export PKEY="' . $this->_sKeyfile . '" ; ';
+            
+            if (is_dir($sWorkdir . ".git")) {
+                // if a subdir .git exists:
+                // Verify if git remote -v contains the current git url
+                // If not, we delete it
+                $sPreCmd='cd "' . $sWorkdir . '" 2>&1 && git remote -v 2>&1 | grep "' . $sGitUrl . '" >/dev/null || ( echo "DELETING .git dir..."; rm -rf .git && rc=$?; echo "rc=$rc"; sleep 1; exit $rc) ';
+                $this->log(__FUNCTION__." - start PRE command <code>$sPreCmd</code>");
+                exec($sPreCmd, $aPreLines, $iRc);
+                if (!$iRc==0){
+                    $this->log(__FUNCTION__." <code>".print_r($aPreLines, 1)."</code> rc=$iRc");
+                }
+            }
 
             if (!is_dir($sWorkdir . ".git")) {
                 $sGitCmd.='mkdir -p "' . $sWorkdir . '" && cd "' . $sWorkdir . '" && ';
                 $sGitCmd.='git init >/dev/null && ';
-                $sGitCmd.='git remote add origin "' . $this->getUrl() . '" 2>&1 && ';
+                $sGitCmd.='git remote add origin "' . $sGitUrl . '" 2>&1 && ';
             } else {
                 $sGitCmd.='cd "' . $sWorkdir . '" 2>&1 && ';
             }
             $sGitCmd.='git ls-remote --heads --tags origin 2>&1 ;';
-            $this->log(__FUNCTION__." start command <code>$sGitCmd</code>");
+            $this->log(__FUNCTION__." - start command <code>$sGitCmd</code>");
             exec($sGitCmd, $aOutput, $iRc);
-            $this->log(__FUNCTION__." command ended with rc=$iRc ". '<pre>'.implode("\n", $aOutput).'</pre>', ($iRc==0 ? 'info':'error'));
+            $this->log(__FUNCTION__." - command ended with rc=$iRc ". '<pre>'.implode("\n", $aOutput).'</pre>', ($iRc==0 ? 'info':'error'));
             if ($iRc == 0) {
 
                 // use cache that getCommitmessageByBranch can access it
@@ -324,9 +337,12 @@ class vcs implements iVcs {
                 $this->_aRemoteBranches = $aReturn;
                 $this->log(__FUNCTION__ . ' '.count($aReturn).' branches: <pre>'.print_r($this->_aRemoteBranches, 1).'</pre>');
                 $this->_cacheRemoteBranches();
+            } else {
+                // $this->_aRemoteBranches = $oCache->read();
+                $this->log(__FUNCTION__." - No git access? --> deleting cache of former fetched branches...");
+                $oCache->delete();
+                $this->_aRemoteBranches = [];
             }
-        } else {
-            $this->_aRemoteBranches = $oCache->read();
         }
         return $this->_aRemoteBranches;
     }
@@ -339,8 +355,10 @@ class vcs implements iVcs {
     public function getRemoteBranches($bIgnoreCache=false) {
         $this->log(__FUNCTION__."($bIgnoreCache) start");
         if (!$this->_aRemoteBranches || $bIgnoreCache) {
-            $this->log(__FUNCTION__."($bIgnoreCache) uncached");
+            $this->log(__FUNCTION__."($bIgnoreCache) --> fetching fresh data");
             $this->_fetchRemoteBranches($bIgnoreCache);
+        } else {
+            $this->log(__FUNCTION__."($bIgnoreCache) --> returning cached data");
         }
         return $this->_aRemoteBranches;
     }