Skip issuing a git checkout if the repository is being cloned for the first time. Instead run a git clone with appropriate flags to properly checkout the repo in one go.
diff --git a/emsdk.py b/emsdk.py
index e618e37..1bf9aff 100644
--- a/emsdk.py
+++ b/emsdk.py
@@ -781,21 +781,21 @@
     return []
 
 
-def git_clone(url, dstpath):
+def git_clone(url, dstpath, branch):
   debug_print('git_clone(url=' + url + ', dstpath=' + dstpath + ')')
   if os.path.isdir(os.path.join(dstpath, '.git')):
     debug_print("Repository '" + url + "' already cloned to directory '" + dstpath + "', skipping.")
     return True
   mkdir_p(dstpath)
-  git_clone_args = []
+  git_clone_args = ['--recurse-submodules', '--branch', branch]  # Do not check out a branch (installer will issue a checkout command right after)
   if GIT_CLONE_SHALLOW:
     git_clone_args += ['--depth', '1']
   print('Cloning from ' + url + '...')
-  return run([GIT(), 'clone', '--recurse-submodules'] + git_clone_args + [url, dstpath]) == 0
+  return run([GIT(), 'clone'] + git_clone_args + [url, dstpath]) == 0
 
 
-def git_checkout_and_pull(repo_path, branch_or_tag):
-  debug_print('git_checkout_and_pull(repo_path=' + repo_path + ', branch/tag=' + branch_or_tag + ')')
+def git_pull(repo_path, branch_or_tag):
+  debug_print('git_pull(repo_path=' + repo_path + ', branch/tag=' + branch_or_tag + ')')
   ret = run([GIT(), 'fetch', '--quiet', 'origin'], repo_path)
   if ret != 0:
     return False
@@ -828,11 +828,12 @@
 
 def git_clone_checkout_and_pull(url, dstpath, branch):
   debug_print('git_clone_checkout_and_pull(url=' + url + ', dstpath=' + dstpath + ', branch=' + branch + ')')
-  success = git_clone(url, dstpath)
-  if not success:
-    return False
-  success = git_checkout_and_pull(dstpath, branch)
-  return success
+
+  # If the repository has already been cloned before, issue a pull operation. Otherwise do a new clone.
+  if os.path.isdir(os.path.join(dstpath, '.git')):
+    return git_pull(dstpath, branch)
+  else:
+    return git_clone(url, dstpath, branch)
 
 
 # Each tool can have its own build type, or it can be overridden on the command