diff --git a/get_addons b/get_addons
index 258f62882d403266c049781517cbb8c424b9fd5d..057f2ad443d904fa7f7ba2688b10a6873c99f893 100644
--- a/get_addons
+++ b/get_addons
@@ -5,6 +5,7 @@ set -e
 ODOO_ROOT_DIR=${ODOO_ROOT_DIR:-'/opt/odoo'}
 SAVE_COMMITS_DIR=${SAVE_COMMITS_DIR:-'/opt/odoo_commits'}
 SAVE_COMMITS_FILENAME=${SAVE_COMMITS_FILENAME:-'custom_addons'}
+TMP_REPO_PATH='/tmp/repo'
 
 save_commit() {
   repo="$1"
@@ -22,18 +23,24 @@ dst="$1"
 shift
 modules="$@"
 
-git clone "${repo}" /tmp/repo
-git -C /tmp/repo checkout "${ref}"
+set +e
+git clone --single-branch --branch "${ref}" --depth 1 "${repo}" "${TMP_REPO_PATH}"
+if [ "$?" -ne 0 ]; then
+git clone "${repo}" "${TMP_REPO_PATH}"
+fi
+set -e
+
+git -C "${TMP_REPO_PATH}" checkout "${ref}"
 commit="$(git -C /tmp/repo rev-parse HEAD)"
 if [ -n "$modules" ]; then
   for module in $modules; do
-    mv "/tmp/repo/${module}" "${ODOO_ROOT_DIR}/${dst}/"
+    mv "${TMP_REPO_PATH}/${module}" "${ODOO_ROOT_DIR}/${dst}/"
     save_commit "$repo" "$commit" "$module" "$dst"
   done
 else
   module="$(basename $dst)"
   mkdir -p "/${ODOO_ROOT_DIR}/${dst}"
-  mv /tmp/repo/* "${ODOO_ROOT_DIR}/${dst}/"
+  mv ${TMP_REPO_PATH}/* "${ODOO_ROOT_DIR}/${dst}/"
   save_commit "$repo" "$commit" "$module" "$dst"
 fi
-rm -r /tmp/repo
+rm -r "${TMP_REPO_PATH}"