Git 推送错误 - 无法将某些引用推送到
我正在尝试将代码上传到我在 github 上创建的存储库,但出现错误。 假设存储库的 URL 是 https://github.com/a,我该如何上传我的代码到我的远程存储库?
在导航到我要上传的文件夹内部后,我在 git bash 上尝试了以下命令 -
git init
(output - Reinitializing existing Git repository in C://(path)/.git/
git add.
(blank output)
git commit -m "Initial commit"
(output- On branch main. nothing to commit, working tree clean)
git remote add origin https://github.com/(path).git
(output - error: remote origin already exists)
git push origin master
(output - error:src refspec master does not match any
error failed to push some refs to https://github.com/(path).git)
为什么会发生这种情况以及我该怎么做才能将代码推送到远程 git 存储库? (我想学习如何通过 cmd 使用 git)
感谢您阅读我的查询!
I am trying to upload my code onto a repository I created on github but I get an error.
Assuming the URL of the repository is https://github.com/a, how do I go about uploading my code to my remote repository?
I tried the following commands on git bash after navigating INSIDE the folder I want to upload -
git init
(output - Reinitializing existing Git repository in C://(path)/.git/
git add.
(blank output)
git commit -m "Initial commit"
(output- On branch main. nothing to commit, working tree clean)
git remote add origin https://github.com/(path).git
(output - error: remote origin already exists)
git push origin master
(output - error:src refspec master does not match any
error failed to push some refs to https://github.com/(path).git)
Why is this happening and what could I do to push my code to my remote git repo? (I want to learn how to use git via cmd)
Thanks for reading my query!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

发布评论
评论(3)
~没有更多了~
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
请注意,您已经将远程存储库配置为
origin
,您必须删除此配置或重命名,然后添加正确的存储库。按名称删除远程存储库的 git 命令是
git remote remove ${repo_name}
,在您的情况下:重命名远程存储库的 git 命令是:
然后您可以添加一个名为 origin 的新远程存储
库可以假设 git 命令 git remote add origin https://github.com/(path).git 表示 git 配置一个新的远程存储库到当前本地存储库,此远程配置将“指向” 到<网址>以及此的“别名”将是“origin”(或您在 之间指定的名称)。
add
和在这种情况下=https://github.com/(path).git
有了这个,您可以拥有各种遥控器,并在执行 git push ${repo_name} 时指定
您可以使用 git pull -u ${repo_name} 为 git pull/status 设置“默认”上游
note that you already have an remote repository configured as
origin
you must remove this configuration or rename then add the correctly repo.the git command to remove remotes repositories by name is
git remote remove ${repo_name}
, in your case:the git command to rename remotes repositories is:
then you can add an new remote with the name origin
you can assume that the git command
git remote add origin https://github.com/(path).git
says to git configure an new remote repository into the current local repository, this remote config will "point" to the <URL> and the "alias" of this <URL> will be "origin" (or the name you specify betweenadd
and <URL>).in this case <URL>=https://github.com/(path).git
With this you can have various remotes and specify then when you execute
git push ${repo_name}
You can set an "default" upstream for git pull/status with
git push -u ${repo_name}