我有一个非常奇怪的问题与git和github。当我试着推的时候,我得到:
git push -u origin master
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
我添加了遥控器:
git remote add origin git@github.com:account-name/repo-name.git
什么好主意吗?
我有一个非常奇怪的问题与git和github。当我试着推的时候,我得到:
git push -u origin master
ERROR: Repository not found.
fatal: The remote end hung up unexpectedly
我添加了遥控器:
git remote add origin git@github.com:account-name/repo-name.git
什么好主意吗?
当前回答
在我的情况下,这是由git使用错误的ssh私钥引起的。 我在学校使用的特定github用户帐户下获得了访问存储库的权限。我的默认ssh私钥不幸链接到不同的github帐户。
如果您使用ssh -T git@github.com ssh将自动使用您的id_rsa私钥连接到github。
使用ssh -i ~/。ssh/<some-key> -T git@github.com应该导致github欢迎您与您链接到该密钥的帐户。
所以在我的情况下发生的是,git正在使用我的默认ssh私钥,该私钥链接到错误的github帐户,该帐户没有访问我试图访问的私有存储库。
为了解决这个问题,我告诉git使用正确的ssh命令在本地git配置我的repo使用命令:git config core。ssh -i ~/.使用实例Ssh /<正确的私钥here>"
查看git配置git config -l应该显示行被正确添加。
其他回答
我的代码片段:
environment {
...
...
git_repo = 'my-repo'
}
stage ('Update Helm Chart') {
steps {
echo 'Updating values.xml file with latest Docker image tag'
withCredentials([usernamePassword(credentialsId: '6bgg7dd45-c65f13-4275-a96ddehdv67gdr', usernameVariable: 'GIT_USER', passwordVariable: 'GIT_PASS')]) {
sh '''
git checkout ${git_branch}
...
...
git remote set-url origin "http://${GIT_USER}:${GIT_PASS}@git.example.com/scm/${git_repo}.git"
git push origin ${git_branch}
'''
}
}
}
我的Git用户名是deploy.user@example.com,所以我必须首先URL编码@ %40。在URL编码之后,我的用户名变成了deploy.user%40example.com。
然而,我仍然得到以下错误:
fatal: repository 'http://****:****@git.example.com/scm/my-repo.git/' not found
经过一些试验和错误,我发现,如果我不使用变量的用户名,而是硬编码它,它的工作。
git remote set-url origin "http://deploy.user%40example.com:${GIT_PASS}@git.example.com/scm/${git_repo}.git"
都经历过同样的问题。几年来一切都很正常,然后突然出现了这个错误。
问题是,我在用户的github SSH密钥(我总是用来访问有问题的回购)之前向我的SSH代理添加了另一个回购的部署密钥。SSH代理首先尝试了另一个回购的部署键,而GitHub出于一些完全无法解释的原因说
ERROR: Repository not found.
一旦我从SSH代理中删除了部署键,一切就恢复正常了。
git remote rm origin
git remote add origin <remote url>
所以对我来说,我的密码有一个'(勾),PhpStorm在发送git推送之前删除了这个字符:
在这个例子中,我的密码是_pa ' ' ssword_
Phpstorm将输出以下内容:
https://_username_:_password_@github.com/_username_/repo.git
而不是
https://_username_ _pa“ssword_@github.com/_username_/repo.git
将密码更改为不使用'字符的密码。工作! !
如果你属于一个组在Github检查你有写访问权。