首页 > 解决方案 > 如何正确地将我的新存储库添加到 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)

标签: gitgithubrepository

解决方案


您不能仅使用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
    

推荐阅读