diff --git a/lib/bb/fetch2/repo.py b/lib/bb/fetch2/repo.py
index 8543e3d59..9b96cd824 100644
--- a/lib/bb/fetch2/repo.py
+++ b/lib/bb/fetch2/repo.py
@@ -73,10 +73,13 @@ class Repo(FetchMethod):
         if scmdata == "keep":
             tar_flags = []
         else:
-            tar_flags = ["--exclude='.repo'", "--exclude='.git'"]
+            tar_flags = ["--exclude=.repo", "--exclude=.git"]
 
         # Create a cache
-        runfetchcmd(['tar'] + tar_flags + ['-czf', ud.localpath, os.path.join(".", "*")], d, workdir=codir)
+        tar_paths = [os.path.join(".", name)
+                     for name in sorted(os.listdir(codir))
+                     if not name.startswith(".")]
+        runfetchcmd(['tar'] + tar_flags + ['-czf', ud.localpath] + tar_paths, d, workdir=codir)
 
     def supports_srcrev(self):
         return False
