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

我打开终端使git按-f

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

我不确定会有什么问题。


当前回答

在Visual Studio中从Github克隆时,点击Github链接上的“浏览存储库”选项,它将要求登录。

其他回答

这可能是身份验证的问题。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/)。

我在VS code中遇到这个错误,因为我正在使用VS code git扩展。它将我的git凭证保存在Linux key-ring上。而我想从另一个帐户的git拉到储存库。 最简单的解决方案是打开Linux shell(不是在VS code中集成的那个),然后运行:

git pull origin master

这一次,它会问你Github的用户名和密码。

增加“个人访问令牌”

自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”。

检查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 }

在我们的案例中,这只是一个在github中授予写权的案例。最初用户只有读权限,它给出了这个错误。