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

我打开终端使git按-f

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

我不确定会有什么问题。


当前回答

更新.git目录中的用户名和令牌。

转到git文件夹,进入。git文件夹,打开“config”文件 使用记事本或任何其他编辑器更改您的URL从 https://github.com/username/repo_name.git https://username:token@github.com/username/repo_name.git 用户名应该没有@域名。 保存并推送代码,它将工作。 在这里,您需要保存密码和 安全威胁。

其他回答

有时ssh凭证是安装在你的电脑上与github回购通信。 当你设置新的repo:如果你添加了https格式的origin,你的git凭证管理器不能找出repo。

检查产地格式

git remote -v

https格式的来源

origin  https://github.com/username/repo_name.git

ssh格式的原点

origin git@github.com:username/repo_name.git

删除https格式的origin

git remote remove origin

添加ssh格式的origin

git remote add origin git@github.com:username/repo_name.git

检查url s.source是否正确。

为我树立榜样

// fail Project>>t<<est

s.source = { :git => '.../Projecttest-iOS', :tag => s.version.to_s }

// success    Project>>T<<est
s.source = { :git => '.../ProjectTest-iOS', :tag => s.version.to_s }

其他答案都不适合我,我可以在浏览器中查看回购,但当试图获取或做一个新的克隆时,得到了Not Found错误。出于某种原因,这解决了问题:

在浏览器中访问Github repo。 点击绿色的“代码”按钮(如下图)。 选择“使用Github桌面打开”。 Github桌面应该打开并成功获取。 你现在可以关闭Github桌面,从控制台或你选择的Git软件中获取或克隆。

我有其他现有的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.com凭据详细信息。

对于mac

从Keychain Access中删除github.com密码。

对于windows

从凭证管理器中删除凭证。