我有一个非常奇怪的问题与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库也有同样的问题。

方法:

使用SSH而不是HTTPS,然后推/拉开始工作正常。

其他回答

我的代码片段:

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"
git remote rm origin
git remote add origin <remote url>

转到你的项目文件夹,然后搜索。git文件夹,然后用记事本打开配置文件,检查是否有你的链接到github回购下:[remote "origin"],如果它是不同的,然后在你的github回购,然后编辑它,或在配置文件中打开一个新的回购名称

这也可能发生,因为GitHub本身宕机了。一定要检查stat.github.com,看看问题是否在他们那边。

2018年10月22日,你有好几个小时都无法推送到GitHub。

另外,一定要检查是否安装了桌面客户端。我仔细检查了一切,我的权限,SSH,但原来我在客户端列出的回购覆盖了我通过终端输入的。