From 5a7e1b7c759cedbe5a898c26b43e3f874c0f8db9 Mon Sep 17 00:00:00 2001 From: Steve Yegge Date: Fri, 31 Oct 2025 21:34:34 -0700 Subject: [PATCH] Fix bd sync git pull command to be explicit about remote and branch --- cmd/bd/sync.go | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/cmd/bd/sync.go b/cmd/bd/sync.go index 9a1bf865..fa9852e3 100644 --- a/cmd/bd/sync.go +++ b/cmd/bd/sync.go @@ -323,7 +323,25 @@ func gitCommit(ctx context.Context, filePath string, message string) error { // gitPull pulls from the current branch's upstream func gitPull(ctx context.Context) error { - cmd := exec.CommandContext(ctx, "git", "pull") + // Get current branch name + branchCmd := exec.CommandContext(ctx, "git", "rev-parse", "--abbrev-ref", "HEAD") + branchOutput, err := branchCmd.Output() + if err != nil { + return fmt.Errorf("failed to get current branch: %w", err) + } + branch := strings.TrimSpace(string(branchOutput)) + + // Get remote name for current branch (usually "origin") + remoteCmd := exec.CommandContext(ctx, "git", "config", "--get", fmt.Sprintf("branch.%s.remote", branch)) + remoteOutput, err := remoteCmd.Output() + if err != nil { + // If no remote configured, default to "origin" + remoteOutput = []byte("origin\n") + } + remote := strings.TrimSpace(string(remoteOutput)) + + // Pull with explicit remote and branch + cmd := exec.CommandContext(ctx, "git", "pull", remote, branch) output, err := cmd.CombinedOutput() if err != nil { return fmt.Errorf("git pull failed: %w\n%s", err, output)