我有本地工作副本SourceTree。和所有的操作工作得很好,我可以简单的获取,推,拉等通过SourceTree。我只需要在SourceTree中不存在的force push。
我打开终端使git按-f
remote: Repository not found.
fatal: repository 'https://github.com/MyRepo/project.git/' not found
我不确定会有什么问题。
我有本地工作副本SourceTree。和所有的操作工作得很好,我可以简单的获取,推,拉等通过SourceTree。我只需要在SourceTree中不存在的force push。
我打开终端使git按-f
remote: Repository not found.
fatal: repository 'https://github.com/MyRepo/project.git/' not found
我不确定会有什么问题。
当前回答
在我的情况下,上述解决方案都不起作用。
我通过将remote.origin.url从https切换到ssh来解决这个问题:
验证git配置:
git config --list
应该是这样:
...
remote.origin.url=https://github.com/ORG/repo-name.git
...
使用SSH更新remote.origin.url:
git remote set-url origin git@github.com:ORG/repo-name.git
其他回答
对于Mac
打开KeyChain访问,并在密码类别上找到您的密码帐户(您可以在右上角KeyChain访问页面上搜索它)
当你找到它时,删除所有与git源代码控制相关的键。再试一次
当存储库、团队名称或用户名更改时,就会发生这种情况。 有一个解决方案(我知道):恢复存储库名称。
其他答案都不适合我,我可以在浏览器中查看回购,但当试图获取或做一个新的克隆时,得到了Not Found错误。出于某种原因,这解决了问题:
在浏览器中访问Github repo。 点击绿色的“代码”按钮(如下图)。 选择“使用Github桌面打开”。 Github桌面应该打开并成功获取。 你现在可以关闭Github桌面,从控制台或你选择的Git软件中获取或克隆。
增加“个人访问令牌”
自2021年以来,Github支持PAT而不是名称/密码(阅读这里如何创建和使用一个),所以我们只是把它添加到远程起源。
在Windows上
访问。git文件夹,打开配置文件进行编辑。如。vim配置。 将URL更改为 https://github.com/ <用户名> / < repo_name > . 来 https:// [personal-access-token] @github.com/ <用户名> / < repo_name > . 其中[personal-access-token]是你在github创建的PAT散列。 保存配置文件,现在推送应该可以工作了。
快捷方式:
git remote remove origin
git remote add origin https://[personal-access-token]@github.com/username/repo_name.git
更新
生成令牌时,如果希望令牌长时间工作,请选择“No expiration”。
在ubuntu上,我遇到了这个问题。我通过运行下面的命令重置凭据帮助器来解决这个问题。
git config credential.helper ""
运行此命令后,当您拉或推时,将要求您再次输入凭据。