我有本地工作副本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
我不确定会有什么问题。
当前回答
我使用gh命令行工具(顺便说一下,这很神奇)
就我而言,我登录了另一个github账户。我只需要运行:
gh auth logout
gh auth login
然后使用正确的帐户进行身份验证流程。
其他回答
这可能是身份验证的问题。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/)。
增加“个人访问令牌”
自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”。
当存储库、团队名称或用户名更改时,就会发生这种情况。 有一个解决方案(我知道):恢复存储库名称。
我也有同样的问题
通过检查http。在git配置中的代理值(我的是不正确的和不需要的), 因此我删除了http。从git配置的代理值
命令:
列出文件中的配置项
git config --list
删除代理
git config --global --unset http.proxy
问题解决了!
我有其他现有的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