无法从远程存储库读取,换句话说 push rejectec

Could not read from remote repository, in other words push rejectec

我正在尝试推送我的分支,进行必要的更改并提交。但是,一旦我在 Android Studio 上按下 push,它就会告诉我 Push 被拒绝并且已 100% 完成检查和测试。对于我所看到的,它与分支的远程起源有关。所以我不太了解 Git 并且它是远程源问题,所以我认为一旦我在“开发人员”分支上签出它就很好,在“开发人员”上创建了一个分支并且显然它不会让我推。一切都已连接,远程源位于正确的位置。这是我所做的以及到目前为止我得到的。

在终端中:

PS E:\Projects\GitHub\Rijs-museum\RijsMuseum> git remote add origin https://github.com/XCMachine/Rijs-museum.git
error: remote origin already exists.
PS E:\Projects\GitHub\Rijs-museum\RijsMuseum> git push feature/description_parameter_change
fatal: 'feature/description_parameter_change' does not appear to be a git repository
fatal: Could not read from remote repository.

在控制台中:

23:05:49.686: [..\..\Rijs-museum] git -c credential.helper= -c core.quotepath=false -c log.showSignature=false push --progress --porcelain origin refs/heads/feature/description_parameter_change:feature/description_parameter_change --set-upstream
Enumerating objects: 50, done.
Counting objects:   2% (1/50)
Counting objects:   4% (2/50)
Counting objects:   6% (3/50)
Counting objects:   8% (4/50)
Counting objects:  10% (5/50)
Counting objects:  12% (6/50)
Counting objects:  14% (7/50)
Counting objects:  16% (8/50)
Counting objects:  18% (9/50)
Counting objects:  20% (10/50)
Counting objects:  22% (11/50)
Counting objects:  24% (12/50)
Counting objects:  26% (13/50)
Counting objects:  28% (14/50)
Counting objects:  30% (15/50)
Counting objects:  32% (16/50)
Counting objects:  34% (17/50)
Counting objects:  36% (18/50)
Counting objects:  38% (19/50)
Counting objects:  40% (20/50)
Counting objects:  42% (21/50)
Counting objects:  44% (22/50)
Counting objects:  46% (23/50)
Counting objects:  48% (24/50)
Counting objects:  50% (25/50)
Counting objects:  52% (26/50)
Counting objects:  54% (27/50)
Counting objects:  56% (28/50)
Counting objects:  58% (29/50)
Counting objects:  60% (30/50)
Counting objects:  62% (31/50)
Counting objects:  64% (32/50)
Counting objects:  66% (33/50)
Counting objects:  68% (34/50)
Counting objects:  70% (35/50)
Counting objects:  72% (36/50)
Counting objects:  74% (37/50)
Counting objects:  76% (38/50)
Counting objects:  78% (39/50)
Counting objects:  80% (40/50)
Counting objects:  82% (41/50)
Counting objects:  84% (42/50)
Counting objects:  86% (43/50)
Counting objects:  88% (44/50)
Counting objects:  90% (45/50)
Counting objects:  92% (46/50)
Counting objects:  94% (47/50)
Counting objects:  96% (48/50)
Counting objects:  98% (49/50)
Counting objects: 100% (50/50)
Counting objects: 100% (50/50), done.
Delta compression using up to 12 threads
Compressing objects:   5% (1/19)
Compressing objects:  10% (2/19)
Compressing objects:  15% (3/19)
Compressing objects:  21% (4/19)
Compressing objects:  26% (5/19)
Compressing objects:  31% (6/19)
Compressing objects:  36% (7/19)
Compressing objects:  42% (8/19)
Compressing objects:  47% (9/19)
Compressing objects:  52% (10/19)
Compressing objects:  57% (11/19)
Compressing objects:  63% (12/19)
Compressing objects:  68% (13/19)
Compressing objects:  73% (14/19)
Compressing objects:  78% (15/19)
Compressing objects:  84% (16/19)
Compressing objects:  89% (17/19)
Compressing objects:  94% (18/19)
Compressing objects: 100% (19/19)
Compressing objects: 100% (19/19), done.
Writing objects:   3% (1/27)
Writing objects:   7% (2/27)
Writing objects:  11% (3/27)
Writing objects:  14% (4/27)
Writing objects:  18% (5/27)
Writing objects:  22% (6/27)
Writing objects:  25% (7/27)
Writing objects:  29% (8/27)
Writing objects:  33% (9/27)
Writing objects:  37% (10/27)
Writing objects:  40% (11/27)
Writing objects:  44% (12/27)
Writing objects:  48% (13/27)
Writing objects:  51% (14/27)
Writing objects:  55% (15/27)
Writing objects:  59% (16/27)
Writing objects:  62% (17/27)
Writing objects:  66% (18/27)
Writing objects:  70% (19/27)
Writing objects:  74% (20/27)
Writing objects:  77% (21/27)
Writing objects:  81% (22/27)
Writing objects:  85% (23/27)
Writing objects:  88% (24/27)
Writing objects:  92% (25/27)
Writing objects:  96% (26/27)
Writing objects: 100% (27/27)
Writing objects: 100% (27/27), 2.10 KiB | 537.00 KiB/s, done.
Total 27 (delta 9), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas:   0% (0/9)        
remote: Resolving deltas:  11% (1/9)        
remote: Resolving deltas:  22% (2/9)        
remote: Resolving deltas:  33% (3/9)        
remote: Resolving deltas:  44% (4/9)        
remote: Resolving deltas:  55% (5/9)        
remote: Resolving deltas:  66% (6/9)        
remote: Resolving deltas:  77% (7/9)        
remote: Resolving deltas:  88% (8/9)        
remote: Resolving deltas: 100% (9/9)        
remote: Resolving deltas: 100% (9/9), completed with 9 local objects.        
error: failed to push some refs to 'https://github.com/XCMachine/Rijs-museum.git'
To https://github.com/XCMachine/Rijs-museum.git
!   refs/heads/feature/description_parameter_change:refs/heads/feature/description_parameter_change [remote rejected] (cannot lock ref 'refs/heads/feature/description_parameter_change': 'refs/heads/feature' exists; cannot create 'refs/heads/feature/description_parameter_change')
Done

最终错误很简单,但让我们一次一个地检查每个错误。

第一个错误

当你运行这个:

git remote add origin https://github.com/XCMachine/Rijs-museum.git

您收到一条错误消息:

error: remote origin already exists.

错误的结果是已经存在的origin没有改变。还好,origincurrent设置好像已经是https://github.com/XCMachine/Rijs-museum.git了。我基于你的控制台输出,它接近尾声:

error: failed to push some refs to
'https://github.com/XCMachine/Rijs-museum.git'

第二个错误

git push feature/description_parameter_change

此命令缺少一个词。第一个词 git 是 运行 的整个命令的名称。第二个词 push 是 Git sub-command 到 运行——Git 的动词。 第三个 单词,应该是 origin,是要对其执行 [=24] 的存储库 的 名称=].由于此处的第三个词是 feature/description_parameter_change,您的 Git 假定这是存储库的名称。但是您的 Git 软件无法找到该名称下的存储库。 (它从未尝试将其作为 b运行ch 名称,因为进入 third-word 槽的东西永远不是 b运行ch 名称。)

(你想要:

git push origin feature/description_parameter_change

在这里。但是,这只会让你得到最后一个错误。)

最后一个错误

最后,Android Studio 推送本身正确调用了 git push。这会将您的新提交(以及所需的任何文件和其他支持对象)发送到 GitHub。但是你遇到了这个问题:

'refs/heads/feature' exists; cannot create
'refs/heads/feature/description_parameter_change'

这里的 refs/heads/ 部分是一个前缀,意思是 这个名字的其余部分是一个 b运行ch 名字 。 (Git 通常会为人类抑制这些额外的东西,但是 Android Studio 在任何地方都使用全名,无论如何你应该知道这一点,因为 Git 本身与 什么时候它human-izes输出,什么时候不输出。)

因此,GitHub 告诉您:我有一个名为 feature 的 b运行ch。您现在要我创建一个名为 feature/description_parameter_change 的新 b运行ch。我做不到。 这里的问题是 Git 有时 1 通过 OS-level 运行ch 存储 b运行ch 名称 folder-and-file-names。如果你创建了一个名为 featurefile,你也不能创建一个名为 featurefolder,这意味着你不能商店 feature/description_parameter_change。由于 Git 可能 使用 OS-level 名称,因此 Git 阻止您创建这样的 b运行ch 名称。

你有两个选择:

  • 让 GitHub 重命名他们的 b运行ch feature,或者
  • 使用 GitHub-side b运行ch 名称而不是 feature/description_parameter_change.

例如,您可以通过使用 GitHub 网络界面重命名您的 GitHub b运行ch 来执行前者。您可以使用 git branch -m 在本地执行后者,例如:

git branch -m feature/description_parameter_change feat-d-p-c

其次是:

git push origin feat-d-p-c

(注意:四个字:command git, verb push, repository name origin, b运行ch name) 这样你的local Git,其(本地)b运行ch 名称,正在使用 feature/description_parameter_change 以外的名称,然后是 Git 的默认值,即询问 GitHub使用 相同的 名称创建一个 b运行ch,将要求 GitHub 创建 feat-d-p-c,它看起来不像一个名为 feature 包含一个文件。


1很久以前,Git总是这样做。然后这变得效率低下,现在 Git 有时 会这样做,但为了以防万一,它确保它总是 可能 。在未来的 Git 版本中,Git 可能永远不会或几乎不会这样做,但为了向后兼容,该限制可能会永远存在。