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

我打开终端使git按-f

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

我不确定会有什么问题。


当前回答

我也面临着同样的问题,正在解决

git add .

git commit -m "message"

git remote set-url origin https://YOUR_GITHUB_USER@github.com/aceofwings/RotairERP.git

then

git pull

其他回答

在Mac

如果您正在尝试克隆repo....然后这个问题可能会发生,因为你没有回购目前在github帐户目前在钥匙串访问。为了解决这个问题,请尝试使用帐户名进行克隆

Git 克隆 https://username@github.com/org/repo.git

取代

用户名与你的GitHub用户名 与您的组织名称 使用存储库名称进行回购

我看到了这个致命的问题:当人们尝试在免费层上从私人GitHub帐户中推拉时,存储库现在更经常地发现错误。以下是最常见的解决方案:

您没有验证 您的密码已更改 你不是合作者 不正确的大小写或拼错的单词 已删除git存储库

Windows凭证管理器?

有时Windows凭证管理器会缓存你的u/p,并在幕后传递它。如果您最近更改了密码,或者使用了不同的用户名,您可能需要进入凭据管理器并清除GitHub的现有条目。

如果你在windows上得到控制面板-> windows凭据,然后从通用凭据选项删除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.

虽然前面的回复提供了各种解决方案,但我发现其中最简单的一个是将用户名添加到存储库的URL中

git remote add origin https://your-username@github.com/your-username/repository-name.git

如果你已经定义了存储库(没有添加用户名),你可以按照以下方式更新它:

git remote set-url origin https://your-username@github.com/your-username/respository-name.git

当推送到远程存储库时,git不会从凭据助手中提取任何其他现有存储库的凭据,而是会询问用户/存储库在URL中定义的特定密码。

一般来说,我会不惜一切代价避免使用您的帐户密码,而是使用个人访问令牌。登录github,选择,

Settings > Developer Settings > Personal Access Tokens > Generate new token

只要确保在定义令牌范围时选中repo,并在要求输入密码时输入令牌(而不是您的个人密码)。