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

我打开终端使git按-f

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

我不确定会有什么问题。


当前回答

这可能是身份验证的问题。SourceTree缓存你的github凭据(用于通过https访问存储库),但从终端你必须使用凭据配置git (https://help.github.com/articles/creating-an-access-token-for-command-line-use/)或使用git+ssh和ssh密钥对(https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/)。

其他回答

〇解决方案

问题,

$ git clone https://github.com/abc/def.git
Cloning into 'def'...
remote: Repository not found.
fatal: repository 'https://github.com/abc/def.git/' not found

解决方案- 卸载凭据管理器-

abc@DESKTOP-4B77L5B MINGW64 /c/xampp/htdocs
$ git credential-manager uninstall

abc@DESKTOP-4B77L5B MINGW64 /c/xampp/htdocs
$ git credential-manager install

它的工作原理……

操作系统

使用VS Code和一个没有密码的密钥:

removed eval "$(ssh-agent -s)" line from my ~/.zshrc file to stop running it in the background (first step on Github's Generating a new SSH key article) verified my .ssh/config entry for *.github.com did not have a UseKeychain line used simply ssh-add ~/.ssh/id_ed25519 with NO --apple-use-keychain on VS Code "Git: Add remote..." allowed/authorized my Github account connection (you don't really need to add a remote) applies a new "vscodevscode.github-authentication" entry in Mac's Keychain Access app closed all shells and VS Code, restarted and the repo is now always found

如果回购是私有的,请确保您已接受回购邀请。如果回购是私有的,而不接受回购邀请,如果你直接推送更改,它会给出相同的错误。

增加“个人访问令牌”

自2021年以来,Github支持PAT而不是名称/密码(阅读这里如何创建和使用一个),所以我们只是把它添加到远程起源。

在Windows上

访问。git文件夹,打开配置文件进行编辑。如。vim配置。 将URL更改为 https://github.com/ <用户名> / < repo_name > . 来 https:// [personal-access-token] @github.com/ <用户名> / < repo_name > . 其中[personal-access-token]是你在github创建的PAT散列。 保存配置文件,现在推送应该可以工作了。

快捷方式:

git remote remove origin
git remote add origin https://[personal-access-token]@github.com/username/repo_name.git

更新

生成令牌时,如果希望令牌长时间工作,请选择“No expiration”。

我通过删除.git文件(隐藏文件夹),然后再次上传解决了这个问题。