cli: "fatal:remote origin already exists" when creating repo
Describe the bug
Version
gh version 1.1.0 (2020-10-06)
https://github.com/cli/cli/releases/latest
Problem
When I want to create a GitHub repo via gh repo create Username/RepoName, I got some error.
Steps to reproduce the behavior
- Type the command
gh repo create Username/new_repo_name - View the output
- You will see error “fatal: remote origin already exists”
Expected vs actual behavior
- Expected: I can create then clone the repo with
gh repo create - actual behavior: I can create the repo, but can’t clone it. I need to run
gh repo cloneto clone it.
Logs
$ gh repo create Emojigit/example
? Visibility Public
? This will create 'Emojigit/example' in your current directory. Continue? Yes
✓ Created repository Emojigit/example on GitHub
fatal: 遠端 origin 已經存在。
git: exit status 128
Translate:
- 遠端: remote
- 已經存在: already exists
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 9
- Comments: 15 (5 by maintainers)
@Emojigit Did you expect a sub-directory to be a created for the new repo instead of it being added as
originremote to the existing git repo?FWIW, what I’m looking to do is create the remote repo from a template and then clone it locally. Should this just be two steps?
@Emojigit Sorry for the bad experience! Right now, gh users get this error when they try to run
gh repo createin an existing local git repository that already has anoriginremote. This is known and we will try to make this a better experience.gh repo createwas meant to either be run outside of a local repository, or inside of a local repository that has no existing git remotes.For the record: when you ran
gh repo create Username/new_repo_name, was your intention to create a new GitHub repo and clone it in a new directory callednew_repo_name?Another strange bug!
@mislav When there is already an
originremote, should we skip this step or ask to change the currentremoteURL? 🤔I am writing some plugins of software that use git, so I need to run the
gh repo createin another repo.It looks like your repo was created: https://github.com/Emojigit/example Am I missing something?
@mislav - I would like to be able to specify the name of the remote when creating a repo.
For example, something like this:
gh repo create --remote-name upstreamThe scenario is that it is a git init’d directory and I want to create a repo and add it as a remote, but I already have origin specified.