         loader (.open repo (.getObjectId twalk 0))]
     (slurp (.openStream loader))))
 
+(defn- repo-exists?
+  [repo-name branch]
+  (.exists (as-file (repo-path repo-name branch))))
+
+(defn- ensure-repo-up-to-date
+  "Gets or updates the specified repo from GIT"
+  [repo-name branch]
+  (if (repo-exists? repo-name branch)
+    (pull-repo repo-name branch)
+    (do
+      (info (str "Repo '" repo-name "' not found - attempting to clone"))
+      (clone-repo repo-name branch))))
+
 (defn get-data
   "Fetches the data corresponding to the given application from GIT"
   [env application readonly]
   (try
-    (clone-repo (repo-branch env application readonly) application)
-    (get-head application)
+    (let [branch (repo-branch env application readonly)]
+      (ensure-repo-up-to-date application branch)
+      (get-head application branch))
     (catch InvalidRemoteException e
       (info (str "Can't communicate with remote repo '" application  "': " e))
       nil)


(defn- get-head
  "Get the contents of the application config file for head revision"
  [application]
  (info "Attempting to get head for the application " application)
  (let [file-name (str application  ".clj")
        git (Git/open (as-file (repo-path application)))
        repo (.getRepository git)
        commit-id (.resolve repo "HEAD")
        rwalk (RevWalk. repo)

            [clj-http.client :as client]
            [clj-time.coerce :refer [from-long]]
            [clj-time.format :refer [unparse formatters]]
            [clojure.string :refer [upper-case lower-case split]]
            [cheshire.core :refer [parse-string]]
            [slingshot.slingshot :refer [try+ throw+]]
            [me.raynes.conch :as conch])
