diff --git a/command/repo.go b/command/repo.go index 5e16f9645..4f8c51e0b 100644 --- a/command/repo.go +++ b/command/repo.go @@ -169,7 +169,7 @@ func addUpstreamRemote(parentRepo ghrepo.Interface, cloneDir string) error { // TODO: support SSH remote URLs upstreamURL := fmt.Sprintf("https://github.com/%s.git", ghrepo.FullName(parentRepo)) - cloneCmd := git.GitCommand("-C", cloneDir, "remote", "add", "upstream", upstreamURL) + cloneCmd := git.GitCommand("-C", cloneDir, "remote", "add", "-f", "upstream", upstreamURL) cloneCmd.Stdout = os.Stdout cloneCmd.Stderr = os.Stderr return run.PrepareCmd(cloneCmd).Run() diff --git a/command/repo_test.go b/command/repo_test.go index e52df1313..cf3fe3423 100644 --- a/command/repo_test.go +++ b/command/repo_test.go @@ -186,7 +186,7 @@ func TestRepoFork_outside_yes(t *testing.T) { eq(t, output.Stderr(), "") eq(t, strings.Join(cs.Calls[0].Args, " "), "git clone https://github.com/someone/repo.git") - eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C repo remote add upstream https://github.com/OWNER/REPO.git") + eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C repo remote add -f upstream https://github.com/OWNER/REPO.git") test.ExpectLines(t, output.String(), "Created fork someone/REPO", @@ -219,7 +219,7 @@ func TestRepoFork_outside_survey_yes(t *testing.T) { eq(t, output.Stderr(), "") eq(t, strings.Join(cs.Calls[0].Args, " "), "git clone https://github.com/someone/repo.git") - eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C repo remote add upstream https://github.com/OWNER/REPO.git") + eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C repo remote add -f upstream https://github.com/OWNER/REPO.git") test.ExpectLines(t, output.String(), "Created fork someone/REPO", @@ -484,7 +484,7 @@ func TestRepoClone_hasParent(t *testing.T) { } eq(t, cs.Count, 2) - eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C REPO remote add upstream https://github.com/hubot/ORIG.git") + eq(t, strings.Join(cs.Calls[1].Args, " "), "git -C REPO remote add -f upstream https://github.com/hubot/ORIG.git") } func TestRepoCreate(t *testing.T) {