我有一个非常奇怪的问题与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
什么好主意吗?
当前回答
有类似的问题。问题的根源是我遵循了一些关于向Github添加新存储库的在线教程。
只要去Github,创建一个新的repo,它会要求你添加一个README,不要添加它。创建它,你会得到如何推送的指导。
它类似于接下来的两行:
git remote add origin https://github.com/YOUR_USER/your-repo.git
git push -u origin master
其他回答
我得到了同样的错误,因为我改变了我的github用户名,然后我这样做:
git remote -v
然后:
git remote set-url newname newurl
git push -u origin master
这次我能够推送到存储库。 我希望这能有所帮助。
我的代码片段:
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重新认证解决了这个问题。
如果你有Github CLI,你可以输入gh auth登录
这对我来说很管用:
1. 的遥控器
$ git remote rm origin
$ git remote add origin git@github.com:<USER>/<REPO>.git
如果您的SSH密钥已经在另一个github代表上使用,您可以生成一个新密钥。
2. 生成新的SSH密钥
$ ssh-keygen -t rsa -b 4096 -C "web@github.com"
3.在SSH代理级别添加密钥
$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa_github
4. 将新密钥添加到Github回购。
这解决了我的问题。
git pull https://myusername:mypassword@github.com/path_to/myRepo.git