我有一个非常奇怪的问题与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
什么好主意吗?
当前回答
我的代码片段:
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"
其他回答
如果你的repo之前工作正常,突然弹出这个错误,最有可能的原因是你的git被认证为其他用户,没有访问存储库的权限。因此,为了进行推送,您所需要做的就是在git命令中指定正确的用户名和密码。所以,一个github回购的推命令看起来像:
git push https://youruser:password@github.com/user/reponame.git
用户名和密码需要进行url转义,因此@应该被%40取代,等等。
我也有同样的问题。
我解决了把我的gitlab用户名前缀到gitlab.com url的问题,就像这样: 之前: https://gitlab.com/my_gitlab_user/myrepo.git 后: https://my_gitlab_user@gitlab.com/my_gitlab_user/myrepo.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"
我可以解释我是如何陷入类似的情况,然后列出我已经采取的步骤来解决这个问题。
我在用 Windows 10, Git: Git版本2.27.0.windows.1。
我已经安装了git,正在做git推送活动。Windows凭据管理器存储用户名和密码,所以你不必每次git远程活动都输入用户名和密码。
遇到这个问题,当我添加了另一个github帐户和使用——本地git设置。几天后,我遇到了存储库找不到的问题,经过调查我发现:
即使你从Windows凭证管理器中删除了git详细信息,它也会再次保存你输入的用户名、电子邮件详细信息。
因此,如果您使用两个git帐户,则需要使用(以管理员身份使用git bash)
git config --edit --system
然后移除
helper = manager
行,使其不再注册为凭据帮助器。但是每次你进行远程活动时,它都会询问你登录的详细信息。
如何禁用Git凭证管理器的Windows?
检查远程源、用户详细信息
git config --list --show-origin
为了解决这个问题(在Linux上),我只需要运行这个:
git config --global --unset credential.helper