我有本地工作副本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
我不确定会有什么问题。
当前回答
这里的问题是你的本地git无法将更改推送到远程 检查你的遥控器是否设置正确
git remote -v
如果没有正确设置,请尝试将您的遥控器设置为
git remote set-url origin https://username@github.com/MyRepo/project.git
然后尝试使用
git push -u origin master
也有可能你的本地git有不同的凭据,请检查一下。
其他回答
我有同样的问题后,我设置了2FA在我的回购。如果你最近在你的账户上设置了2FA,下面是我解决这个问题的方法:
生成一个个人访问令牌
去设置->开发人员设置->个人访问令牌在你的GitHub帐户。生成一个新的个人访问令牌。确保检查所有与repo访问相关的权限。
删除所有GitHub认证配置(从Mac的keychain)
您需要使用生成的个人访问令牌重新登录,因此要清除笔记本电脑上以前的所有身份验证细节。对于mac,打开keychain并从登录/密码部分删除所有github.com相关细节。
用你的GitHub用户名和PAT作为密码登录到你的终端。
如果您在帐户上设置了2FA,则无法使用您的帐户进行身份验证 来自终端的GitHub密码。现在,尝试推送到GitHub回购以触发身份验证需求。你的终端上会弹出一个输入你的GitHub用户名的请求。输入您的用户名,并在提示输入密码时,使用生成的个人访问令牌作为密码。
这些步骤为我解决了问题。
禁用GIT证书对我有帮助:
git config --global --unset credential.helper
我有其他现有的github存储库,但我错误地认为我可以使用git命令创建存储库。我认为我的问题是没有个人访问令牌,但我仍然不能使用下面的命令来创建我的存储库。
git init
git add README.md
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/username/project.git
git push -u origin main
我不断地得到:
remote: Repository not found.
fatal: repository 'https://github.com/username/project.git/' not found
作为对
git push -u origin main
然而,我发现存储库需要创建使用github cli或在他们的github网站登录到我的帐户后。一旦我这样做了,一切都很顺利。
下面是我发现我不能用git命令创建github存储库的链接。
https://docs.github.com/en/get-started/importing-your-projects-to-github/importing-source-code-to-github/adding-an-existing-project-to-github-using-the-command-line
对我的团队来说,这是一个权限问题。在GitHub设置中,我们团队中的所有成员都将其设置为阅读模式。一旦我们将下拉菜单更改为“写入”,我们就都能够成功地克隆和推回。
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.