我有一个非常奇怪的问题与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
什么好主意吗?
当前回答
我也有同样的问题。试试下面的方法: 1. 修改密钥链访问在Mac的git凭证解决了我的问题。 2. 重置原始url
git remote rm origin
git remote add origin git@github.com:account-name/repo-name.git
其他回答
我的代码片段:
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,创建一个新的repo,它会要求你添加一个README,不要添加它。创建它,你会得到如何推送的指导。
它类似于接下来的两行:
git remote add origin https://github.com/YOUR_USER/your-repo.git
git push -u origin master
这也可能发生,因为GitHub本身宕机了。一定要检查stat.github.com,看看问题是否在他们那边。
2018年10月22日,你有好几个小时都无法推送到GitHub。
Github于2021年8月13日删除了用户名和密码的使用。现在改用个人代币
要克服这一点,请使用create personal token生成个人令牌。并使用下面的代码片段来实现推送和克隆功能。
推动
git remote remove origin
git remote add origin https://[USER]:[TOKEN]@github.com/[USER]/[REPO]
git push
克隆
git clone https://[USER]:[TOKEN]@github.com/[USER]/[REPO]
我的一个Github库也有同样的问题。
方法:
使用SSH而不是HTTPS,然后推/拉开始工作正常。