这是什么意思:' rebase(1/4) '当我做' pull -v——rebase=merges ',当只有一个提交?



我有下一个提交:

* be23d923d (HEAD -> bot) Dump more info
* 506b1b5a7 (office/bot) Fix IP for registry.gitlab.office
* fb7e89677 Show build log on failure
*   58c2e3606 Merge branch 'implement_test' into test2

运行git pull -v --rebase=merges后,结果为:

* 42852fd6b (HEAD -> bot) Dump more info
* a3c657c09 (office/bot) Echo $IMAGE_TAG
* 506b1b5a7 Fix IP for registry.gitlab.office
* fb7e89677 Show build log on failure
*   58c2e3606 Merge branch 'implement_test' into test2

下面是该命令的日志:

remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 2), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), 287 bytes | 287.00 KiB/s, done.
From office-repo:office/bot
506b1b5a7..a3c657c09  bot        -> office/bot
= [up to date]          prod       -> office/prod
Changes from 506b1b5a7ebcf0e9778279f5de90bd67c0462e0a to a3c657c099ea0077a22d77de10029dd35be1058d:
.gitlab-ci.yml | 1 +
1 file changed, 1 insertion(+)
Rebasing (1/4)
Rebasing (2/4)
Rebasing (3/4)
.gitlab-ci.yml | 1 +
1 file changed, 1 insertion(+)
Successfully rebased and updated refs/heads/bot.

我们可以看到远程存储库上只有on commit:

git log -w -b -p --ignore-blank-lines --full-history 506b1b5a7..a3c657c09
commit a3c657c099ea0077a22d77de10029dd35be1058d (office/bot)
Author: Administrator <admin@example.com>
Date:   Sun Dec 18 15:54:06 2022 +0000
Echo $IMAGE_TAG
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 4ca4f8769..e4e25a947 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -23,6 +23,7 @@ build-job:
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER $CI_REGISTRY --pass>
- docker build -t $IMAGE_TAG .
- docker push $IMAGE_TAG
+    - echo $IMAGE_TAG

test-job1:
stage: test

为什么有三个碱基,而我期望有一个?Git还会提交最后一次重新编译吗?
(显示1/4、2/4、3/4,无Rebase 4/4)

您在这里使用--rebase=merges,这意味着您的拉命令使用git rebase --rebase-merges来进行重基。

如果您只使用git pull -v --rebase进行测试,您将看到您所期望的单个重置步骤。

但是对于--rebase=merges,您可以将其分解为git fetchgit rebase --rebase-merges -i office/bot-i将让我们看到它将要应用的重基步骤。

这是我在模拟情况下得到的结果:

label onto
reset onto
pick 2f840de bar

,这意味着有4条rebase指令。仍然认为空行是一条指令,但我确认它是:如果您删除空行,rebase日志显示(n/3)而不是(n/4)

这些额外的步骤需要处理合并,如果有的话。在这种情况下,没有任何,但步骤仍然存在,因为我猜git rebase --rebase-merges即使看到没有合并也不会优化它们。