我有一个非常奇怪的问题与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不熟悉你的存储库。

Error:在git cli中提示如下:

remote:未找到存储库。致命:库 “https://github.com/MyOrganization/projectName.git/”未找到

解决方案:2个选项

Github might not familiar with your credentials: - The first Option is to clone the project with the right credentials user:password in case you forgot this Or generate ssh token and adjust this key in your Github. aka git push https://<userName>:<password>@github.com/Company/repositoryName.git Repo Permissions Issue with some users - In my Use case, I solved this issue when I realized I don't have the right collaborator permissions on Github in my private repo. Users could clone the project but not perform any actions on origin. In order to solve this:

去Github上的仓库->设置->合作者和团队->添加 成员/维护你的用户->现在他们获得了提交的权限 ,推动

我的代码片段:

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"

我在一台MAC上遇到了同样的问题,试图从我以前连接到的一个私人回购中提取。

我通过在回购url中包含我的用户名来解决这个问题:

git remote set-url origin https://<YOUR_USER_NAME_HERE>@github.com/<YOUR_USER_NAME_HERE>/<REPO>.git

然后我从回购中提取了数据。

对于一个你想克隆的新回购:

git clone https://<YOUR_USER_NAME_HERE>@github.com/<YOUR_USER_NAME_HERE>/<REPO>.git    

它会提示你输入那个账户的密码,然后你就可以去了。

eval "$(ssh-agent -s)"

这是我自己的回购——应该有足够的使用权。对于其他回购,我能够拉和推没有问题。通过重新启动ssh-agent解决了这个问题。我用macos。

我需要杀死凭证帮助进程(有多个),它在再次提供凭证后解决了这个问题。

killall git-credential-cache——守护进程