Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

let user to specify the target repo fork name #4849

Open
chmouel opened this issue Dec 3, 2021 · 4 comments · May be fixed by #4886
Open

let user to specify the target repo fork name #4849

chmouel opened this issue Dec 3, 2021 · 4 comments · May be fixed by #4886

Comments

@chmouel
Copy link

@chmouel chmouel commented Dec 3, 2021

Describe the feature or problem you’d like to solve

We are able to repo a fork with :

$ gh repo fork

this forks upstream of for example the repository foo to the github user repositories foo (or organisation if specified as is)

it would be nice if we can have the ability to have another name than foo as the user repository target.

Proposed solution

$ gh repo fork --fork-name="forked-repo"

Additional context

I have multiple repos with name "enhancement" from different organization, i need to rename all manually after doing a "gh repo fork" so they won't conflict 😢

  • maybe users can get confused with the already existing --remote-name switch
@shortyfatt2000

This comment has been minimized.

@mislav
Copy link
Member

@mislav mislav commented Dec 6, 2021

Hi, thank you for the feature request. This would have been a good addition to the CLI; unfortunately the API that we use does not support choosing the fork name at fork time: https://docs.github.com/en/rest/reference/repos#create-a-fork

You can call an additional command to rename your fork with gh repo rename -R owner/my-project new-fork-name, but that won't help if there is already an unrelated owner/my-project repository at the time of forking somebody-else/my-project. It looks like name clashes are unavoidable until the platform gets the feature to choose the new name in the API request.

@mislav
Copy link
Member

@mislav mislav commented Dec 6, 2021

Update: I just tested and it looks like on name collisions, the new fork in your account will have a number appended to the forked repo in case you already have a repository matching the name of the repository you're forking. The fork will get named myowner/repo-2 in case you already have myowner/repo. Since this works without erroring out, GitHub CLI could actually take the desired fork name as argument and rename the repository post-forking! Contributions welcome 👍

Tip: see pkg/cmd/repo/rename for an existing repo-renaming implementation that could be borrowed from or reused

@g14a g14a linked a pull request that will close this issue Dec 11, 2021
@g14a
Copy link
Contributor

@g14a g14a commented Dec 11, 2021

@mislav I tried fixing this by the approach you mentioned i.e renaming it after forking. I've opened a PR #4886. Do give feedback on what changes can be done here thank you :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

6 participants
@mislav @chmouel @g14a @shortyfatt2000 @cliAutomation and others