Skip to content

Fix: Honor --remote flag when repository specified via argument#12691

Open
drtootsie wants to merge 1 commit intocli:trunkfrom
drtootsie:fix-fork-remote-flag
Open

Fix: Honor --remote flag when repository specified via argument#12691
drtootsie wants to merge 1 commit intocli:trunkfrom
drtootsie:fix-fork-remote-flag

Conversation

@drtootsie
Copy link

Fixes #2722

Summary

The --remote flag was being ignored when a repository was specified as an argument to gh repo fork.

Changes

Modified the early return logic in fork.go to properly check the --remote flag in both scenarios:

  • When forking from within a parent repository
  • When forking a repository specified via argument

Testing

All existing tests pass:

cd pkg/cmd/repo/fork && go test -v

Fixes cli#2722

The --remote flag was being ignored when a repository was specified
as an argument. This was due to the early return logic combining
both inParent and !inParent conditions in a single check.

Split the early return into two separate conditions:
- For inParent: return early only if neither Remote nor PromptRemote
- For !inParent: return early only if none of Clone, PromptClone, Remote, or PromptRemote

This ensures the --remote flag is respected in both scenarios.
@drtootsie drtootsie requested a review from a team as a code owner February 15, 2026 22:41
@cliAutomation cliAutomation added the external pull request originating outside of the CLI core team label Feb 15, 2026
@github-actions
Copy link

Thank you for your pull request! 🎉

This PR appears to fix the following issues that are not labeled with help wanted Contributions welcome :

As outlined in our Contributing Guidelines, we expect that PRs are only created for issues that have been labeled help wanted.

While we appreciate your initiative, please note that:

  • PRs for non-help wanted issues may not be reviewed immediately as they might not align with our current priorities
  • The issue might already be assigned to a team member or planned for a specific release
  • We may need to close this PR. For example, if it conflicts with ongoing work or architectural decisions

What happens next:

  • Our team will review this PR and the associated issues
  • We may add the help wanted label to the issues, if appropriate, and review this pull request
  • In some cases, we may need to close the PR. For example, if it doesn't fit our current roadmap

Thank you for your understanding and contribution to the project! 🙏

This comment was automatically generated by cliAutomation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external pull request originating outside of the CLI core team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Repo fork ignores the --remote flag when specifying a repository via argument

2 participants