aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CONTRIBUTORS2
-rw-r--r--pkg/vcs/git.go7
2 files changed, 7 insertions, 2 deletions
diff --git a/CONTRIBUTORS b/CONTRIBUTORS
index 2df5346c0..03faf74dd 100644
--- a/CONTRIBUTORS
+++ b/CONTRIBUTORS
@@ -104,4 +104,4 @@ Sabyrzhan Tasbolatov
Adam Goska
Kouame Behouba Manassé
Junquan Zhou
-
+Liz Prucka
diff --git a/pkg/vcs/git.go b/pkg/vcs/git.go
index 63901b850..f6f6ee276 100644
--- a/pkg/vcs/git.go
+++ b/pkg/vcs/git.go
@@ -103,7 +103,12 @@ func (git *git) CheckoutBranch(repo, branch string) (*Commit, error) {
return nil, err
}
repoHash := hash.String([]byte(repo))
- // Ignore error as we can double add the same remote and that will fail.
+ // Because the HEAD is detached, submodules assumes "origin" to be the default
+ // remote when initializing.
+ // This sets "origin" to be the current remote.
+ // Ignore errors as we can double add or remove the same remote and that will fail.
+ git.git("remote", "rm", "origin")
+ git.git("remote", "add", "origin", repo)
git.git("remote", "add", repoHash, repo)
_, err := git.git("fetch", "--force", repoHash, branch)
if err != nil {