564

我对gitand有一个非常奇怪的问题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

有任何想法吗?

4

61 回答 61

734

检查您是否具有读写访问权限。

Git 错误消息具有误导性。我有一个类似的问题。我已被添加到现有项目中。我克隆了它并提交了本地更改。我去推送并收到ERROR: Repository not found.错误消息。

将我添加到项目中的人授予我对存储库的只读访问权限。他们的改变,我能够推动。

于 2012-04-19T19:04:31.257 回答
252

我有同样的问题,有一个私人回购。

请执行下列操作:

删除远程源

git remote rm origin

重新添加来源,但使用您的用户名和密码,并在此 pvt 存储库上具有写入权限

git remote add origin  https://USERNAME:PASSWORD@github.com/username/reponame.git
于 2017-04-20T16:57:56.853 回答
163

我遇到了同样的问题,我通过在 repo url 中包含我的用户名和密码来解决它:

git clone https://myusername:mypassword@github.com/path_to/myRepo.git
于 2013-10-20T15:30:42.427 回答
92

如果您在Windows上使用 Git ,请尝试清除您的凭据:

  1. 找到“凭据管理器”(应该在您的控制面板中)
  2. 删除与 GitHub 相关的所有凭据

在此处输入图像描述

于 2018-07-04T22:57:27.230 回答
83

我遇到了同样的错误

ERROR: Repository not found.   
fatal: The remote end hung up unexpectedly

我在 Github 上创建了存储库并将其克隆到本地。

我能够通过打开 .git/config 并删除该[remote "origin"]部分来解决。

[remote "origin"]   
   url = git@github.com:alexagui/my_project.git  
   fetch = +refs/heads/*:refs/remotes/origin/*

然后我运行以下(再次)

git remote add origin git@github.com:alexagui/my_project.git  
git push -u origin master

这一次我能够推送到存储库。

于 2012-05-18T22:20:20.457 回答
43

我收到了这个错误(但之前正在工作)。我的问题是缺少与 Github 帐户绑定的 ssh 密钥。您可以使用 . 检查您当前的 ssh 密钥ssh-add -l

如果您的密钥丢失,您可以添加它

ssh-add ~/.ssh/your_key
于 2013-01-15T11:36:03.327 回答
27

我正在使用 Mac,我很难找到解决方案。我的远程地址是正确的,如前所述,这是一个凭据问题。显然,过去我在我的计算机上使用了另一个 Git 帐户,并且 mac 的钥匙串记住了以前帐户的凭据,所以我真的没有被授权推送。

怎么修?在 Mac 上打开Keychain Access,选择“所有项目”类别并搜索 git。 删除所有找到的结果。

现在转到终端并尝试再次推送。终端将询问用户名和密码。输入新的相关凭据,就是这样!

希望它会帮助某人。我挣扎了几个小时。

于 2018-06-22T14:23:08.227 回答
27

我有一个类似的问题。不正确的凭据被缓存在 OS X 的钥匙串中。

查看:https ://help.github.com/articles/updating-credentials-from-the-osx-keychain

于 2015-12-15T14:54:13.837 回答
25
git remote rm origin
git remote add origin <remote url>
于 2013-10-29T09:24:39.790 回答
20

remote: Repository not found.尝试推送到您没有写入权限的 HTTPS 远程时,这可能是来自的令人沮丧的误导性错误消息。

检查您对存储库的写入权限!

尝试使用 SSH 远程访问同一存储库会显示不同的响应:

% git remote add ssh git@github.com:our-organisation/some-repository.git

% git fetch ssh
From github.com:our-organisation/some-repository
* [new branch]        MO_Adding_ECS_configs             -> ssh/MO_Adding_ECS_configs
* [new branch]        update_gems                       -> ssh/update_gems

% git push ssh     
ERROR: Repository not found.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

“正确的访问权限?”

你为什么不这么说呢?

在这一点上值得注意的是,虽然这种情况下的 SSH 故障模式稍微好一些,但我使用 HTTPS 远程而不是 SSH,因为 GitHub推荐HTTPS over SSH

我了解 GitHub 在某些情况下使用“未找到”表示“禁止”,以防止无意中发现私有存储库的存在。

在某些地方,需要身份验证的请求将返回404 Not Found,而不是 。403 Forbidden这是为了防止私有存储库意外泄漏给未经授权的用户。

-- GitHub

这是网络上相当普遍的做法,实际上它是这样定义的:

404(未找到)状态代码表示源服务器没有找到目标资源的当前表示或不愿意透露存在的表示。

——6.5.4 。404 Not Found,RFC 7231 HTTP/1.1 语义和内容(强调我的)

对我来说没有意义的是,当我使用 凭证助手通过 GitHub 进行身份验证 并且我可以访问该存储库(已成功克隆并获取它)时,GitHub 会因为缺少写权限而选择对我隐藏它的存在。

使用网络浏览器检查https://github.com/our-organisation/some-repository/确认我没有对存储库的写入权限。我们团队的 GitHub 管理员能够在短时间内授予我的团队写入权限,并且我能够将分支向上推。

于 2018-12-20T08:29:13.633 回答
16

如果你的 repo 之前工作正常,突然弹出这个错误,很可能是因为你的 git 被认证为其他用户,没有访问存储库的权限。因此,为了推送,您需要做的就是在您的 git 命令中指定正确的用户名和密码。因此,github repo 的推送命令如下所示:

git push https://youruser:password@github.com/user/reponame.git

username and password需要进行 url 转义,因此@应替换为%40,依此类推。

于 2019-03-22T16:29:18.453 回答
11

我在尝试推送到私有仓库时也遇到了这个错误,但问题不在于仓库是私有的还是公共的,问题是 Github API 现在使用个人令牌进行身份验证和授权。

以下解决了我的问题:

  1. 删除远程来源:git remote remove origin

  2. 生成个人令牌:您可以在Github Docs中找到说明。

  3. 重新添加来源,但使用您的用户名和生成的令牌:

git remote add origin https://USERNAME:GENERATED_TOKEN@github.com/username/reponame.git

于 2021-09-25T11:15:39.683 回答
11

这对我有用:

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代理级别的key的添加

$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa_github

4. 将新密钥添加到 Github 存储库。

于 2017-05-23T11:50:50.770 回答
10

如果您属于 Github 中的某个组,请检查您是否具有写入权限。

于 2015-05-09T23:02:24.020 回答
10

一个问题,对于我在这里没有提到的一些人来说可能很明显,可能是您可以使用 ssh 密钥访问,但您正试图通过 https 将本地存储库连接到远程。

如果是这种情况,那么以下命令应该可以为您解决问题:

$ git remote -v
origin  https://github.com/private-repo.git (fetch)
origin  https://github.com/private-repo.git (push)
$ git remote rm origin
$ git remote add origin git@github.com:private-repo.git
$ git remote -v
origin  git@github.com:private-repo.git (fetch)
origin  git@github.com:private-repo.git (push)

请注意,上述工作假设:

  1. 您当前的遥控器已命名origin,并且您已经生成了与您的 github 帐户连接的 ssh 密钥

  2. 您已经有一个与您的 github 帐户关联的 ssh 密钥(并在本地连接)

  3. 您在 github 上为此 repo 的设置设置了正确的权限(读/写)。

于 2018-03-16T13:41:43.473 回答
9

有类似的问题。问题的根源在于我遵循了一些关于将新存储库添加到 Github 的在线教程。

去 Github,创建一个新的 repo,它会要求你添加一个 README,不要添加它。创建它,您将获得有关如何推送的说明。

它类似于接下来的两行:

git remote add origin https://github.com/YOUR_USER/your-repo.git
git push -u origin master
于 2013-03-28T23:05:47.223 回答
8

我在尝试从我之前连接的私人仓库中提取的 MAC 上遇到了同样的问题。

我通过在 repo 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    

它会提示您输入该帐户的密码,然后您就可以继续了。

于 2020-08-07T13:17:26.507 回答
8

这解决了我的问题。

   git pull https://myusername:mypassword@github.com/path_to/myRepo.git
于 2017-01-03T10:47:09.127 回答
7

问题:由于某种原因,Github 不熟悉您的存储库。

错误:在 git cli 中提示如下:

远程:未找到存储库。致命:未找到存储库'<a href="https://github.com/MyOrganization/projectName.git/" rel="noreferrer">https://github.com/MyOrganization/projectName.git/'

解决方案: 2个选项

  1. Github 可能不熟悉您的凭据: - 第一个选项是使用正确的凭据克隆项目,user:password以防您忘记了这个或生成 ssh 令牌并在您的 Github 中调整此密钥。又名git push https://<userName>:<password>@github.com/Company/repositoryName.git

  2. 一些用户的回购权限问题- 在我的用例中,当我意识到我在我的私人回购中没有正确的 Github 合作者权限时,我解决了这个问题。用户可以克隆项目,但不能对源执行任何操作。为了解决这个问题:

转到 Github 上的存储库 -> 设置 -> 协作者和团队 -> 添加成员/维护者您的用户 -> 现在他们获得了提交和推送的权限

于 2019-12-18T13:53:29.577 回答
6

您需要检查您的 SSH 访问权限,如下所示:

ssh -T git@github.com

这个问题是因为我没有在存储库中添加关于 SSH 的人员响应,请阅读有关 SSH link-1link-2的更多信息。

于 2014-09-02T11:52:39.737 回答
5

遇到过同样的问题。多年来一切都运行良好,然后突然出现这个错误。

问题是我在我的用户的 github SSH 密钥(我总是用来访问有问题的 repo)之前为我的 SSH 代理添加了另一个 repo 的部署密钥。SSH 代理首先尝试了另一个 repo 的部署密钥,而 GitHub 出于某种完全无法解释的原因说

ERROR: Repository not found.

从 SSH 代理中删除部署密钥后,一切都恢复正常。

于 2014-11-09T14:15:51.513 回答
5

我有同样的问题。请尝试以下操作:

1. 修改 Mac 中的钥匙串访问以获取 git 凭据解决了我的问题。
2. 重置原始地址

git remote rm origin
git remote add origin git@github.com:account-name/repo-name.git
于 2017-09-08T07:31:22.820 回答
5

我的 Github 存储库之一遇到了同样的问题。

方法:

使用SSH而不是HTTPS然后push/pull开始正常工作。

于 2020-07-29T20:07:55.300 回答
5

这是解决我的问题的方法

#check current github account
ssh -T git@github.com

#ensure the correct ssh key used with github
ssh-agent -s
ssh-add ~/.ssh/YOUR-GITHUB-KEY

#re-add the origin
git remote add origin git@github.com:YOUR-USER/YOUR-REPO.GIT
git push -u origin master
于 2017-01-05T05:06:42.993 回答
5

如果你从 github 克隆 usinghttps但你正在使用ssh推送,你也可以得到这个错误。

要更正此问题,请打开.git/config并替换:

url = https://github.com/company/project.git

url = git@github.com:company/project.git

而且你应该能够毫无警告地推动......

于 2019-11-18T16:21:45.613 回答
5

以下为我解决了这个问题。

首先,我使用这个命令来确定使用的 github 帐户是什么:

ssh -T git@github.com

这给了我这样的答案:

Hi <github_account_name>! You've successfully authenticated, but GitHub does not provide shell access. I just had to give the access to fix the problem.

然后我了解到答案中描述的 Github 用户(github_account_name)在我试图拉取的 Github 存储库中没有得到授权。

于 2016-04-22T18:40:35.343 回答
4

正如 Alex 上面所说,更改 .git/config 文件的内容会有所帮助。我遇到了同样的问题,我认为这是因为我更改了 Github 用户名。无法使用更改更新本地文件。因此,也许每当您更改用户名时,您可能会考虑运行

git remote add origin your_ssh_link_from_github

我希望这有帮助 ;)

于 2012-08-08T12:09:56.850 回答
4

为了解决这个问题(在 Linux 上),我只需要运行这个:

git config --global --unset credential.helper
于 2020-12-30T16:38:08.577 回答
4

如果有人在 github.com 上遇到问题,请检查您是否在回购所有者允许向您提交后接受了邀请。在您接受邀请之前,您将无法看到 repo。所以你会得到ERROR: Repository not found.

于 2016-09-27T11:04:20.853 回答
4

我可以解释我是如何陷入类似情况的,然后会列出我为解决这个问题而采取的步骤。

我正在使用
Windows 10,
git:git 版本 2.27.0.windows.1。

我已经设置了 git 并且正在进行 git push 活动。Windows 凭据管理器存储用户名和密码,因此您不必在每次 git 远程活动时输入用户名和密码。

当我添加另一个 github 帐户并使用 --local git 设置时,遇到了这个问题。几天后,我遇到了 Repository not found 问题,经过调查我发现:

  1. 即使您从 Windows 凭据管理器中删除了 git 详细信息,它也会再次保存您输入的用户名、电子邮件详细信息。

所以,如果你使用两个 git 账户,你需要使用 (git bash as an administrator)

git config --edit --system 

并删除

helper = manager 

行,使其不再注册为凭证助手。但每次您进行任何远程活动时,它都会询问您的登录详细信息。

如何禁用适用于 Windows 的 Git 凭据管理器?.

要检查远程来源,用户详细信息

git config --list --show-origin
于 2020-08-14T06:45:13.087 回答
3

通常会发生这种情况,因为该项目是私有的,您无权编写它。我有几次同样的“问题”,就是因为这个原因。如果项目是您的,只需在此链接之后创建一个私钥和一个公钥:https ://docs.github.com/en/github/authenticating-to-github/generating-a-new-ssh-key-and -adding-it-to-the-ssh-agent并将它们添加到 gitHub 上的“SSH 和密钥”部分,然后你就可以推送到 repo。另一方面,如果该项目不是您的,请要求所有者授予您该项目的权利。

于 2021-01-20T08:56:21.083 回答
3

只需使用 SSH 远程 URL 而不是 HTTPS

于 2020-11-09T14:21:14.373 回答
3

我通过使用 Github 重新进行身份验证解决了这个问题。

如果你有 Github CLI,你可以输入gh auth login

于 2021-10-08T10:10:40.653 回答
2

I had the same problem. My issue was misunderstanding that I had to first create the empty repo on github before pushing to it. Doh! Including this here for anyone else who doesn't realize.

于 2012-10-01T13:29:54.860 回答
2

我遇到了这个问题,并意识到我使用的帐户与它所在的帐户不同。以原始用户身份登录解决了该问题。

于 2015-02-27T22:37:23.497 回答
2

如果您使用私有存储库,请检查您的连接用户,它必须具有使用存储库的权限。

于 2014-04-01T11:11:15.560 回答
2

在执行此操作之前,请确保您已写入 repo 的权限。如果您仍然收到错误,请执行以下操作:

  1. 通过设置 > 开发人员设置 > 个人访问令牌从您的帐户生成个人访问令牌。将令牌安全地保存在某处。

  2. 转到您的存储库并运行以下命令:

    git remote rm origin

  3. 然后添加一个新的来源以及您的用户名:

    git remote add origin https://USERNAME@github.com/REPOSITORY_LINK.git

  4. 现在,当您推送代码时,将出现一个提示,询问您的密码或个人访问令牌。将我们在第一步中生成的令牌粘贴到该字段中,我们就完成了。

于 2021-11-18T13:16:28.770 回答
1

转到您的项目文件夹,然后搜索 .git 文件夹,然后用记事本打开配置文件并检查是否有指向 github repo 的链接:[remote "origin"],如果它与您的 github 中的 repo 不同然后只需编辑它,或使用配置文件中的名称打开一个新的 repo

于 2013-01-11T19:45:54.737 回答
1

我的解决方案可能对你们中的一些人有用。

将我的 macbook 的操作系统更新到 Yosemite 后,我遇到了同样的错误。我的问题通过重新创建我的 ssh 密钥得到了解决。您可以按照此页面的第 2 步执行此操作:https ://help.github.com/articles/generating-ssh-keys/

于 2014-11-25T13:15:16.857 回答
1

我遇到了同样的问题并尝试了很多方法,但最后,我必须知道我没有足够的权限来推送或拉取这个 repo,还有一种方法可以检查你是否拥有权限无法在该存储库中看到设置选项,如果您有权限,那么您将能够看到设置选项

谢谢!这是我观察到的

于 2020-03-12T07:39:11.433 回答
1

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

killall git-credential-cache--daemon

于 2018-05-14T08:26:59.157 回答
1

我的问题是我创建了一个没有权限的个人开发者令牌

于 2021-10-03T22:25:29.183 回答
1

我的解决方案是这样的:

git remote rm origin
git remote add origin https://USERNAME@github.com/username/reponame.git

类似于 Emi-C 的答案,但没有密码。

于 2022-01-05T13:28:16.253 回答
1

在此处输入图像描述

步骤1:

从 HTTPS 复制链接

第2步:

在本地存储库中

git remote rm origin

第 3 步

在复制的 url 中用 username.password@github.com 替换 github.com

第4步:

git remote add origin url
于 2021-03-24T07:12:27.347 回答
1

自 2021 年 5 月以来,我(和许多其他人)遇到了这个问题。actions/checkout@v2 中似乎发生了一些变化(GitHub 问题:https ://github.com/actions/checkout/issues/254 )

我通过使用此步骤更改运行器对存储库进行身份验证的方式来解决它。

- name: Bump version
    env:
      NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}}
    run: |
      npm run release
      git remote rm origin
      git remote add origin https://${{github.actor}}:${{secrets.GITHUB_TOKEN}}@github.com/project/repo.git
      git remote -v # for debug only 
      git show-ref # for debug only 
      git push --follow-tags origin HEAD:master

您需要做的就是更改 repo url。GitHub 运行程序将在运行时替换用户名和密码。这适用于两者actions/checkout@v1actions/checkout@v2(尚未测试其他人)。

此外,您在网上找到的许多片段都带有权限限制,这将阻止您退回回购协议

permissions:
   packages: write
   contents: read

如果您需要推送标签或提交发行说明和包颠簸,请确保删除此内容或授予您的操作内容:写入权限。

于 2021-07-30T07:14:32.820 回答
1

所以对我来说,我的密码中有一个 `(勾号),并且 PhpStorm 在发送 git push 之前删除了该字符:

让我们说这个例子我的密码是_pa``ssword_

Phpstorm 将输出以下内容:

https://_username_:_password_@github.com/_username_/repo.git

代替

https://_username_:_pa``ssword_@github.com/_username_/repo.git

将密码更改为不使用 ` 字符的密码。作品!!!

于 2017-04-19T17:53:10.273 回答
0

首先在命令行新建一个仓库,名字如Ademo.git

在命令行上创建一个新的存储库

touch README.md git init git add README.md git commit -m "first commit" git remote add origin https://github.com/your_name/Ademo.git git push -u origin master

从命令行推送现有存储库

git remote add origin https://github.com/your_name/Ademo.git git push -u origin master

于 2014-03-12T08:48:44.183 回答
0

如果您包含您的用户名和 repo 名称,我们可以合理地帮助您,目前我们没有理由认为 repo 确实存在。

此外,如果 repo 是私有的并且您无权访问它,github 会返回“不存在”以避免披露私有 repos 的存在。

编辑:如果您无法克隆它,因为它说它不存在并且它是私有的,那是因为您没有发送身份验证。确保将您的公钥添加到您的密钥环中,或暂时使用 HTTP 基本身份验证。

于 2012-04-12T02:07:09.080 回答
0

创建一个分叉

如果没有对该存储库的写入权限,则不需要它。按照这些说明创建一个分支——它是您自己的存储库克隆,您可以自由修改。

创建分叉后,您可以将该存储库克隆到您的计算机。

git clone git@github.com:<your-git-handle>/<repository>.git
// It will be cloned to your machine where you run the command 
// under a <repository> folder that it will create.

签出一个新分支并进行更改。

git checkout -b my-new-feature

要将您的更改提交到原始存储库,您需要确保它们已被推送

/* make changes */
git commit -am "New Feature: Made a new feature!"
git push origin my-new-feature

要将这些更改添加到您从中分叉的原始存储库中,您可以按照这些说明提交拉取请求。拉取请求基本上,您请求对存储库具有写入权限的用户拉下您所做的更改。可以将其想象为“我要求您将我的更改拉入您的仓库”。


注意:但是,您的 fork 不会与原始存储库中正在进行的所有更改保持同步。您必须定期删除这些更改——但这很容易。

创建分叉后,您可以链接到您从中分叉的存储库,以便您可以提取它的更改并保持最新状态。

git remote add upstream git@github.com:<git-user-handle>/<repository>.git

完成此操作后,与对原始存储库所做的更改保持同步非常容易。

git checkout master         // checkout your local master
git pull upstream master    // fetch changes from the master branch of the repo you forked from.. which is linked to your fork under the alias "upstream" (common naming convention)
git push origin master      // push the pulled changes onto your local master
git checkout -b new-branch  // create a new branch and start making changes
于 2014-12-06T01:49:41.207 回答
0

将我的 ubuntu 更新到下一个版本后,我遇到了同样的错误

我刚刚在 github 帐户上删除了我的 sshkey,然后重新向该帐户添加了一个 sshkey。

于 2012-11-06T09:08:51.843 回答
0

我得到了同样的错误,因为我更改了我的 github 用户名,然后我这样做:

git remote -v

然后:

git remote set-url newname newurl 
git push -u origin master

这次我能够推送到存储库。我希望这有帮助。

于 2013-01-15T03:36:21.360 回答
0

我在使用Android Studio时遇到了同样的问题,由于身份验证错误,我无法推送提交。

我工作的临时解决方案是使用GitHub 桌面应用程序来推送我的提交,它工作正常。

于 2020-07-09T09:34:07.413 回答
0

我也有同样的问题。

我解决了将我的 gitlab 用户名添加到 gitlab.com url 的问题,如下所示:之前: https ://gitlab.com/my_gitlab_user/myrepo.git 和之后: https://my_gitlab_user@gitlab.com/my_gitlab_user/myrepo.git 在这种情况下,将再次要求提供凭据并完成!

于 2018-10-24T14:05:29.047 回答
0

在我的情况下,这是由 git 使用错误的 ssh 私钥引起的。我在学校使用的特定 github 用户帐户下获得了对存储库的访问权限。不幸的是,我的默认 ssh 私钥链接到了不同的 github 帐户。

如果你这样做,ssh -T git@github.comssh 将自动使用你的id_rsa私钥连接到 github。

使用ssh -i ~/.ssh/<some-key> -T git@github.com应该会导致 github 使用您链接到该密钥的帐户向您致意。

所以在我的情况下发生的事情是 git 使用了我的默认 ssh 私钥,该私钥链接到了错误的 github 帐户,该帐户无权访问我试图访问的私有存储库。

为了解决这个问题,我告诉 git 在本地 git 配置中为我的 repo 使用正确的 ssh 命令,使用以下命令:git config core.sshCommand "ssh -i ~/.ssh/<correct private key here>"

查看 git 配置git config -l应该显示该行已正确添加。

于 2021-11-05T12:46:17.423 回答
0

这也可能发生,因为 GitHub 本身已关闭。确保检查 status.github.com 以查看问题是否出在他们这边。

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

于 2018-10-22T09:48:31.187 回答
0

如果您确定您已经拥有对此存储库的 SSH 访问权限。

git clone https://myusername@github.com/path_to/myRepo.git
于 2022-01-26T13:51:22.627 回答
0

我的代码片段:

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"
于 2020-02-22T06:57:11.820 回答
0

这个答案是特定于IntelliJ产品的,例如使用组织时的IDEA/WebStorm/PHPStorm

当我尝试推送到属于组织的存储库时,我遇到了 WebStorm 的这个问题,同时推送到我正常私人帐户中的存储库是有效的。

此外,使用 IntelliJ IDEA 推送到我的组织存储库也有效

所以我认为这可能只是与两个 IDE 之间不同的设置有关,我发现我在 WebStorm 中启用了“使用凭证助手”复选框,并在 IDEA 中禁用了复选框。

在此处输入图像描述

禁用凭证助手使其工作!

于 2022-01-08T08:38:06.090 回答
-1

还要确保检查您是否安装了桌面客户端。我仔细检查了所有内容,我的权限,SSH,但事实证明我在客户端中列出的存储库覆盖了我通过终端输入的存储库。

于 2015-03-27T18:51:39.830 回答
-1

您必须生成 ssh 密钥并将其添加到您的 github 帐户中的设置转到您的项目,在其中克隆运行这些命令。-

1-ssh-keygen -t rsa -b 4096 -C“rajankumar148@gmail.com”

命令之后你会得到一些选项路径和名称可以留空,你可以输入密码。

2-eval $(ssh-agent -s) 。

3-ssh-add ~/.ssh/id_rsa

在此命令之后,您必须输入在第一个命令中创建的相同密码

然后你可以检查你的默认主目录或它在终端上显示的任何目录 .pub 文件打开并复制密钥并在 github settings new ssh 中过去

于 2021-02-15T16:40:21.670 回答
-1

使用Ubuntu时,我总是必须使用 SSH 而不是 HTTPS 添加远程

git remote add origin git@github.com:username/project.git

代替

git remote add origin https://github.com/username/project.git
于 2021-06-29T17:25:36.920 回答