我有本地工作副本SourceTree。和所有的操作工作得很好,我可以简单的获取,推,拉等通过SourceTree。我只需要在SourceTree中不存在的force push。

我打开终端使git按-f

remote: Repository not found.
fatal: repository 'https://github.com/MyRepo/project.git/' not found

我不确定会有什么问题。


当前回答

确保您拥有正确的访问权限,当分支受到保护时可能会发生这种情况。

我刚刚浪费了四个小时在这上面。

其他回答

试试这个,对我很管用。

git remote rm origin
git remote add origin https://github.com/your-username/{{project-name}}.git

我在VS code中遇到这个错误,因为我正在使用VS code git扩展。它将我的git凭证保存在Linux key-ring上。而我想从另一个帐户的git拉到储存库。 最简单的解决方案是打开Linux shell(不是在VS code中集成的那个),然后运行:

git pull origin master

这一次,它会问你Github的用户名和密码。

我有同样的问题,并发现我在~/中有另一个密钥文件。ssh到不同的GitHub存储库。不知怎么的,它代替了新的。

我尝试了所有的方法,直到我意识到存储库所有者只给了我READ权限,所以Git会抛出“remote: repository not found”。

我使用gh命令行工具(顺便说一下,这很神奇)

就我而言,我登录了另一个github账户。我只需要运行:

gh auth logout
gh auth login

然后使用正确的帐户进行身份验证流程。