From 5fb98ae9a195fecb4cd3d4e48cc1fa9e4b19367b Mon Sep 17 00:00:00 2001
From: jurgenhaas <juergen@paragon-es.de>
Date: Sat, 14 Oct 2017 14:16:20 +0200
Subject: [PATCH] #2 Fetch before tracking remote branch

---
 src/Handler.php | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/Handler.php b/src/Handler.php
index 9fecb7c..9fc8fd3 100644
--- a/src/Handler.php
+++ b/src/Handler.php
@@ -115,11 +115,11 @@ class Handler {
       $fs->mkdir($path);
       $repository->init();
       $repository->addRemote('origin', $uri);
-      $repository->getCaller()->execute('branch --set-upstream-to origin/' . $version . ' ' . $version);
     }
 
     $repository->fetch();
     $repository->checkout($version);
+    $repository->getCaller()->execute('branch --set-upstream-to origin/' . $version . ' ' . $version);
   }
 
 }
-- 
GitLab