cli: Known problems with `repo create` command
The gh repo create
command right now has separate and potentially confusing behaviors when ran inside an existing local git repository vs. outside of it.
Bugs:
- Remote
origin
already exists https://github.com/cli/cli/issues/2166 #893 - Can’t create a new repo while within a repo https://github.com/cli/cli/issues/2059
- Takes parent directory instead of current directory name https://github.com/cli/cli/issues/2026
- Confusing prompt
This will create 'your-repo-name' in your current directory. Continue? (Y/n)
#1913 #2180 https://github.com/cli/cli/pull/2295 https://github.com/cli/cli/pull/2214 https://github.com/cli/cli/pull/2507 - Do not offer INTERNAL visibility option if it’s not supported on the platform https://github.com/cli/cli/issues/2106
- Have
repo create
pick up the default branch setting on GitHub #1810 - Repo create: local directory for new repo not created when non-interactive and --confirm #2587
Features:
- Ask to git init https://github.com/cli/cli/issues/2099 https://github.com/cli/cli/issues/1280
- Specify the base dir for the new repo https://github.com/cli/cli/issues/2077
- Create with gitignore and license files #1907
- Expose more repository settings https://github.com/cli/cli/issues/995
- After initializing a repo with a template pull down changes https://github.com/cli/cli/issues/2290
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 23
- Comments: 32 (9 by maintainers)
@dhanushkac Yes, running
gh repo create
inside an existing git repo that has no git remotes is supposed to create the GitHub project for that repo (taking the directory name as the default project name) and add it as theorigin
remote.Just for organizational purposes, here are the current designs related to issues listed out here. I can update if these evolve in their respective discussions
Creating a repo with git init, licenses, and gitignore
gh repo list
@ardazeytin The PR where
--template
was added has some additional info: https://github.com/cli/cli/pull/1590Basically,
--team
is unsupported because the API endpoint to create a repository from a template doesn’t accept--team
. We could theoretically try to make a separate API request to give the team access after the repo has been created, but I’m not sure if that would work with the current permissions model.You may absolutely open a feature request with this, but note that since it would involve an API change on GitHub, fixing it might take us longer than with features that don’t require any new APIs.
Is it a valid usage that running
gh repo create
inside existing repo?@sun: Ah, I didn’t realize some old versions of git don’t have
-C
. Thanks for letting us know!@g14a: We marked this issue “core” because the bugs are maybe too gnarly to be taken on by a regular contributor, but you are far from a regular contributor 😉 So go right ahead if you feel confident you can tackle some of the bugs listed above. 🙇
@eacp: Which templates do you mean? But in general yes, we prefer to fetch most data over API instead of storing it. GitHub CLI doesn’t work in offline mode.
ℹ️ If you see the following error with
gh repo create
then ensure you have the latest version ofgit
installed.☝️ You might have to add a different package repository for your OS/distribution to retrieve the latest version.
@eacp Sorry for the late reply!
I think that adding a license and/or gitignore files via a specialized command is a good feature to have in general, not just while creating a new repository. But we need to discuss first with the team to see if we want to greenlight the feature. We’ll update the thread(s) when we decide that this is something we want in core.
Thank you for the feedback!
Hello @ampinsk, this design looks very good. However, I was wondering if we could decouple the generation of files from the
gh repo create
command, and instead use commands likegh repo license
orgh repo ignore
in order to keepgh repo
more modular. This is just a proposal tho, it looks very good right now.Given that there are only two actions items left in this tracking issue and:
I’m going to close this. Shout out to @pxrth9 and @meiji163 whose work on rewriting
repo create
solved a big pile of the command’s issues.@samcoe It looks like somebody 😆 updated the package in brew… gh --version gh version 2.4.0 (2021-12-21) https://github.com/cli/cli/releases/tag/v2.4.0
…problem solved, thanks!
@helaili Thanks for reporting! As a workaround, specify the project name as argument:
gh repo create my-project
.Hi,
I want to be able to create repo from template and also i want to give direct access to a team with this single line command at the below.
gh repo create organization/repo-001 --template "organization/test-template-repo" --private --team "teamname"
However, I am getting this warning message.
The '--template' option is not supported with '--homepage, --team, --enable-issues or --enable-wiki'
I would like learn why I can not do this and Why I have to give direct access to team from web browser? Can we count this as feature request?
I can’t seem to get this to work in an empty directory, not only in a directory with a repo inside already:
From reading the rest of this issue that should only be happening when the repo already exists, right?