我有一个非常奇怪的问题与git和github。当我试着推的时候,我得到:

git push -u origin master
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly

我添加了遥控器:

git remote add origin git@github.com:account-name/repo-name.git

什么好主意吗?


当前回答

对我来说,这些回答都没用。 我只是忘记在远程(github.com)上创建回购。所以我在网上创建了我的回购,用同样的名字,然后重新做

所以,这是整个故事:

git init ...
git add ...
git commit ...
git remote add origin git@github.com:<myName>/<myRepo>.git
git push -u origin main

ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

这里你需要在github.com上添加你的回购,使用相同的“myRepo”名称

git push -u origin main 

其他回答

我得到了同样的错误,因为我改变了我的github用户名,然后我这样做:

git remote -v

然后:

git remote set-url newname newurl 
git push -u origin master

这次我能够推送到存储库。 我希望这能有所帮助。

转到你的项目文件夹,然后搜索。git文件夹,然后用记事本打开配置文件,检查是否有你的链接到github回购下:[remote "origin"],如果它是不同的,然后在你的github回购,然后编辑它,或在配置文件中打开一个新的回购名称

如果你的repo之前工作正常,突然弹出这个错误,最有可能的原因是你的git被认证为其他用户,没有访问存储库的权限。因此,为了进行推送,您所需要做的就是在git命令中指定正确的用户名和密码。所以,一个github回购的推命令看起来像:

git push https://youruser:password@github.com/user/reponame.git

用户名和密码需要进行url转义,因此@应该被%40取代,等等。

使用Ubuntu时,我总是需要使用SSH而不是HTTPS添加远程

git remote add origin git@github.com:username/project.git

而不是

git remote add origin https://github.com/username/project.git

我的问题是我创建了一个没有权限的个人开发人员令牌