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

我打开终端使git按-f

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

我不确定会有什么问题。


当前回答

我也面临着同样的问题

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

我卸载了git凭证管理器并重新安装了它,然后我就可以很容易地将它拉到存储库中。下面是命令

$ git credential-manager uninstall

$ git credential-manager install

其他回答

I was trying to clone a repo and was facing this issue, I tried removing all git related credentials from windows credentials manager after that while trying to clone git was asking me for my credentials and failing with error invalid username or password. This was happening because the repo I was trying to clone was under an organization on github and that organization had two factor auth enabled and git bash probably do not know how to handle 2fa. So I generated a token from https://github.com/settings/tokens and used the github token instead of password while trying to clone the repo and that worked.

我有同样的问题后,我设置了2FA在我的回购。如果你最近在你的账户上设置了2FA,下面是我解决这个问题的方法:

生成一个个人访问令牌

去设置->开发人员设置->个人访问令牌在你的GitHub帐户。生成一个新的个人访问令牌。确保检查所有与repo访问相关的权限。

删除所有GitHub认证配置(从Mac的keychain)

您需要使用生成的个人访问令牌重新登录,因此要清除笔记本电脑上以前的所有身份验证细节。对于mac,打开keychain并从登录/密码部分删除所有github.com相关细节。

用你的GitHub用户名和PAT作为密码登录到你的终端。

如果您在帐户上设置了2FA,则无法使用您的帐户进行身份验证 来自终端的GitHub密码。现在,尝试推送到GitHub回购以触发身份验证需求。你的终端上会弹出一个输入你的GitHub用户名的请求。输入您的用户名,并在提示输入密码时,使用生成的个人访问令牌作为密码。

这些步骤为我解决了问题。

您以前可能使用其他GitHub凭据登录。这就是错误发生的原因。

通常,mac将您的GitHub凭据存储到密钥链访问工具。你以前的git帐户详细信息在那里。所以它与你当前在其他账户中的git回购不匹配。

解决方法简单明了,

进入你的mac的钥匙链访问。 在左边的类别下,你可以找到所有的项目。单击。 右边顶部搜索“git”。 你会得到一些关于Github的项目。 删除所有这些项目。

就这样,给你。

再推一下。它会询问你git的用户名和密码。您的新凭证将再次存储在钥匙链中,您的推送将完成。

华友世纪!

如果你需要更多的帮助,再来找我。

谢谢

因为您可能没有首先将远程git存储库标识到您的终端。

git remote set-url origin https://github.com/MyRepo/project.git

然后,

git add .
git commit -m "initial commit"
git push origin master

在我的情况下,上述解决方案都不起作用。

我通过将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