@@ -16,6 +16,7 @@ type pushOptions struct {
1616 auto bool
1717 draft bool
1818 skipPRs bool
19+ remote string
1920}
2021
2122func PushCmd (cfg * config.Config ) * cobra.Command {
@@ -32,6 +33,7 @@ func PushCmd(cfg *config.Config) *cobra.Command {
3233 cmd .Flags ().BoolVar (& opts .auto , "auto" , false , "Use auto-generated PR titles without prompting" )
3334 cmd .Flags ().BoolVar (& opts .draft , "draft" , false , "Create PRs as drafts" )
3435 cmd .Flags ().BoolVar (& opts .skipPRs , "skip-prs" , false , "Push branches without creating or updating PRs" )
36+ cmd .Flags ().StringVar (& opts .remote , "remote" , "" , "Remote to push to (defaults to auto-detected remote)" )
3537
3638 return cmd
3739}
@@ -75,7 +77,7 @@ func runPush(cfg *config.Config, opts *pushOptions) error {
7577 }
7678
7779 // Push all active branches atomically
78- remote , err := pickRemote (cfg , currentBranch )
80+ remote , err := pickRemote (cfg , currentBranch , opts . remote )
7981 if err != nil {
8082 if ! errors .Is (err , errInterrupt ) {
8183 cfg .Errorf ("%s" , err )
@@ -225,11 +227,16 @@ func humanize(s string) string {
225227 }, s )
226228}
227229
228- // pickRemote determines which remote to push to. It delegates to
230+ // pickRemote determines which remote to push to. If remoteOverride is
231+ // non-empty, it is returned directly. Otherwise it delegates to
229232// git.ResolveRemote for config-based resolution and remote listing.
230233// If multiple remotes exist with no configured default, the user is
231234// prompted to select one interactively.
232- func pickRemote (cfg * config.Config , branch string ) (string , error ) {
235+ func pickRemote (cfg * config.Config , branch , remoteOverride string ) (string , error ) {
236+ if remoteOverride != "" {
237+ return remoteOverride , nil
238+ }
239+
233240 remote , err := git .ResolveRemote (branch )
234241 if err == nil {
235242 return remote , nil
0 commit comments