diff --git a/comp.py b/comp.py
index bbc92ec63d876626a256447197c8c5be34807e3c..fe9fe8bbd679fa649c2d1ff85703663fc3165f21 100755
--- a/comp.py
+++ b/comp.py
@@ -6,6 +6,7 @@
 #  - lancement automatique de la batterie
 
 from parametricJob import *
+import re
 
 # -- repository classes --------------------------------------------------------
 
@@ -14,15 +15,33 @@ class Repo(object):
         self.name = name
         self.url = url
 
+
 class GitRepo(Repo):
     def __init__(self, name, url):
         super(GitRepo, self).__init__(name, url)
+
     def co_cmd(self, pars):
-        cmd = "git clone --branch %s --depth %s --quiet %s %s" % \
-            (pars['GIT_BRANCH'].val, pars['GIT_DEPTH'].val, 
+        depth = ''
+        if not pars['GIT_FULLCLONE'].val:
+            depth = '--depth %s' % pars['GIT_DEPTH'].val
+        branch = pars['GIT_BRANCH'].val
+        if not self.doesBranchExist(branch):
+            print 'INFO: branch %s does not exist on %s' % (branch, self.url)
+            branch = 'master'            
+            print 'INFO: checking out %s' % branch
+        cmd = "git clone --branch %s %s --quiet %s %s" % \
+            (branch, depth, 
             self.url, self.name)
         return cmd
 
+    def doesBranchExist(self, name):
+        cmd = ['git', 'ls-remote', '--heads', self.url, name]
+        out = subprocess.check_output(cmd)
+        out = out.decode()  # python 3 returns bytes
+        m = re.search(name, out)
+        return (m != None)    
+
+
 class SVNRepo(Repo):
     def __init__(self, name, url):
         super(SVNRepo, self).__init__(name, url)
@@ -30,6 +49,7 @@ class SVNRepo(Repo):
         cmd = "svn co --quiet %s %s" % (self.url, self.name)
         return cmd
 
+
 # -- CompJob class -------------------------------------------------------------
 
 class CompJob(ParametricJob):
@@ -65,13 +85,14 @@ class CompJob(ParametricJob):
         TextPRM(self.pars,  'NB_TASKS',     'nb of tasks launched in parallel', "1")
         TextPRM(self.pars,  'NB_THREADS',   'nb of threads by task', "1")
 
+        YesNoPRM(self.pars,  'GIT_FULLCLONE', 'clone the whole repository', False)
         TextPRM(self.pars,  'GIT_DEPTH',   'git clone depth', '10')
         TextPRM(self.pars,  'GIT_BRANCH',  'git branch name', 'master')
 
         MultiPRM(self.pars, 'RUNMETHOD',    'Run Method', ["interactive", "at", "batch"], "batch")
         TextPRM(self.pars,  'AT_TIME' ,     'Delay for at launch (no syntax check, use with care)', "now")
 
-        MultiPRM(self.pars, 'UNZIP',     'source', ["zip", "checkout", "present"], "zip")
+        MultiPRM(self.pars, 'UNZIP',     'source', ["zip", "checkout", "present"], "checkout")
         YesNoPRM(self.pars, 'COMPILE',   'compile', True)
         MultiPRM(self.pars, 'BATTERY',   'battery', [True, False, "continue"], True)
 
@@ -80,8 +101,9 @@ class CompJob(ParametricJob):
         PRMAction(self.actions, 'c', self.pars['CMAKELIST'])
         PRMAction(self.actions, 'd', self.pars['DEBUG_MODE'])
 
-        PRMAction(self.actions, 'e', self.pars['GIT_DEPTH'])
-        PRMAction(self.actions, 'f', self.pars['GIT_BRANCH'])
+        PRMAction(self.actions, 'e', self.pars['GIT_FULLCLONE'])
+        PRMAction(self.actions, 'f', self.pars['GIT_DEPTH'])
+        PRMAction(self.actions, 'g', self.pars['GIT_BRANCH'])
 
         PRMAction(self.actions, 'h', self.pars['NICE_VALUE'])
         PRMAction(self.actions, 'j', self.pars['NB_TASKS'])
@@ -108,7 +130,7 @@ class CompJob(ParametricJob):
         self.pars['CMAKELIST'].enable(self.pars['COMPILE'].val==True)
         self.pars['DEBUG_MODE'].enable(self.pars['COMPILE'].val==True)
         self.pars['NICE_VALUE'].enable(self.pars['BATTERY'].val!=False and self.pars['RUNMETHOD'].val!='sge')
-        self.pars['GIT_DEPTH'].enable(self.pars['UNZIP'].val=="checkout")
+        self.pars['GIT_DEPTH'].enable(self.pars['UNZIP'].val=="checkout" and not self.pars['GIT_FULLCLONE'].val)
         self.pars['GIT_BRANCH'].enable(self.pars['UNZIP'].val=="checkout")
         # Batch
         self.pars['AT_TIME'].enable(self.pars['RUNMETHOD'].val=='at')