git - 如何正确地将我的新存储库添加到 github - 找不到存储库
问题描述
有人可以指导我在 Github 上发布我的新存储库吗?
我试图在与我之前使用的文件夹不同的文件夹中再次初始化 git。
所以我在我的 Windows 计算机上创建了一个新文件夹 My_tableau_projects。我里面有两个文件。
然后我跑了
$ git init
$ git add .
$ git commit -m "first commit"
$ git remote add origin https://github.com/bluetail14/My_Tableau_projects.git
error: remote origin already exists.
我想我有这个错误,因为起初我在 github 上创建了一个同名的存储库,但后来我删除了它,因为我不确定是否需要先创建它。
然后我尝试
$ git branch -M main
$ git push -u origin main
remote: Repository not found.
fatal: repository 'https://github.com/bluetail14/My_Tableau_projects.git/' not found
所以我不知道如何继续..它说存储库已经存在但它说找不到?
我在我的 github 上创建一个新的存储库并将我的文件移动到其中的正确程序是什么?
现在我有
$ git remote -v show
origin https://github.com/bluetail14/My_Tableau_projects.git (fetch)
origin https://github.com/bluetail14/My_Tableau_projects.git (push)
解决方案
您不能仅使用git
命令行在 GitHub 上创建新存储库,因为您应该使用 GitHub 自己的 CLI:https ://cli.github.com/manual/gh_repo_create
gh repo create My_Tableau_projects
然后,您可以将 repo 的来源设置为 github URL 并推送到它,基本上按照本文中从第 8 步开始的步骤进行操作。
- 在命令提示符下,添加将推送本地存储库的远程存储库的 URL。
$ git remote add origin <REMOTE_URL> # Sets the new remote $ git remote -v # Verifies the new remote URL
- 将本地存储库中的更改推送到 GitHub。
$ git push origin main # Pushes the changes in your local repository up to the remote repository you specified as the origin
推荐阅读
- python - Python/Regex - 匹配与另一个正则表达式匹配的所有句子
- android-studio - Android Studio 4.0:杀死模拟器进程
- android - 如何检查用户是否已经在 Android Studio 中通过 Spotify 登录?
- wpf - 跨视图模型共享模型的 C# WPF 最佳实践
- python - Airflow BranchPythonOperator - 分支后继续
- google-maps - 使用 Google Cloud 中的长 TLD 限制 API 密钥访问?
- c - 结构名称末尾的 * 运算符与结构名称前面的 * 运算符有什么区别?
- excel - 在同一文件夹中另存为电子表格的宏
- android - 在 web 视图中加载网站时反应原生白色空白屏幕
- python - 将 datetime.timedelta 添加到数据帧切片 (.loc) 未在数据帧中正确更新