github - 使用git remote add添加远程仓库时失败,提示remote: Repository not found.

浏览:29日期:2023-09-01

问题描述

我先创建了本地仓库git_tutorialgithub - 使用git remote add添加远程仓库时失败,提示remote: Repository not found.

github - 使用git remote add添加远程仓库时失败,提示remote: Repository not found.github - 使用git remote add添加远程仓库时失败,提示remote: Repository not found.

然后参考git官方教程使用git remote add origin添加远程仓库

接着使用git remote查看显示已经有了origin仓库

结果当使用git push origin master的时候遇到了如下错误:github - 使用git remote add添加远程仓库时失败,提示remote: Repository not found.

显示仓库没有找到。想问问题出在哪?如何解决?查了stackoverflow有人说git remote add这种方法就是等同于在github上new repository:github - 使用git remote add添加远程仓库时失败,提示remote: Repository not found.我认为这种说法是正确的,但是很多人告诉我必须先在github上建立了仓库才可以使用3和4步骤,到底是哪种说法对呢?如果是后者,那感觉使用git bash都没什么用了...

后面我在GitHub上面建了仓库,再做那git remote和git push origin master两个操作,也出错了:github - 使用git remote add添加远程仓库时失败,提示remote: Repository not found.github - 使用git remote add添加远程仓库时失败,提示remote: Repository not found.

后面照着廖雪峰的教程还有GitHub上YueLinHo的回答push成功了:github - 使用git remote add添加远程仓库时失败,提示remote: Repository not found.

谢谢各位答疑解惑。

问题解答

回答1:

git remote add这种方法就是等同于在 github 上 new repository

git remote add 只是本地添加一个 reference 而已,不负责新建 repo

你现在的问题是,因为没有配置 UserName 和 Email,所以才会报这些错。这里都提示你了:

github - 使用git remote add添加远程仓库时失败,提示remote: Repository not found.

github - 使用git remote add添加远程仓库时失败,提示remote: Repository not found.

解决方案:git config --global user.name 'xxx'git config --global user.email 'xxx@xxx.xxx'其中 xxx 都换成你自己的。

另外你说,'如果是后者,那么 gitbash 就没什么用了'。。为什么?(如果你提交的全是 markdown,没有其他任何代码,那就当我没问)只给你一个 github 网页,请问你如何提交自己的 commit?

回答2:

确实是你的远程仓库必须提前有。整过过程也就是将你的远程仓库和本地仓库做一个链接。之后就可以直接向远程仓库提交了....

回答3:

提交远程的前提确实是先得有远程库才行,但这个远程库不一定非得是github的,gitlab、coding一样可以;另外bash也不是必须要用的,我现在就是装了个git之后,设置库的用户名密码和远程地址这类事用TortoiseGit来做,然后提交、分支(开分支和切分支)和push/pull都是直接用编辑器来做的(用的是vscode,bash我直接挂到编辑器里了,偶尔需要用命令的时候,比如git fetch -p这类操作还是用bash更方便),常用操作是可以不用bash的。

回答4:

必须先在github上建立了仓库才可以的。为什么?你想想,你 git remote add 的时候都没要求你输入用户名和密码,而git push就需要。如果这样不需要密码就会创建仓库,那我可以随意创建别人的仓库了。

回答5:

要先创建仓库

回答6:

git push -u origin master

相关文章: