threads / discuss / 55552

git pull --rebase silently skipping commits

Subject: git pull --rebase silently skipping commits

## tl;dr

One message between Apr 24, 2021 and Apr 24, 2021.

replies: 0people: 1as markdown or json

Alejandro Colomar (man-pages)· Apr 24, 2021, 13:46 UTC · lore
Hello,

I started my PC and as always did a 'git fetch'. I noticed that I forgot to push a commit the other day, so I had the following situation:

alx@msi:~/src/alx/config$ git tree -8
* 226e73c - Thu, 22 Apr 2021 22:28:37 +0200 (2 days ago) (tag: v0.8.0, 
origin/main, origin/HEAD)
|           Makefile: ffix - Alejandro Colomar
* 29cac15 - Thu, 22 Apr 2021 22:21:56 +0200 (2 days ago)
|           Makefile: remove unused option of read - Alejandro Colomar
* 5adc827 - Thu, 22 Apr 2021 22:20:16 +0200 (2 days ago)
|           Makefile: use INSTALL_DATA instead of plain install - 
Alejandro Colomar
* 28df09e - Thu, 22 Apr 2021 22:12:40 +0200 (2 days ago)
|           Makefile: Don't hardcode things - Alejandro Colomar
* 9cdb873 - Thu, 22 Apr 2021 22:11:32 +0200 (2 days ago)
|           ssh: Simplify code, and don't overwrite other contents of 
.ssh/config - Alejandro Colomar
| * 4d2f5ad - Thu, 22 Apr 2021 19:22:16 +0200 (2 days ago) (HEAD -> main)
|/            sudo: Rename user alex to alx - Alejandro Colomar
* ad1d205 - Thu, 22 Apr 2021 12:51:10 +0200 (2 days ago) (tag: v0.7.0)
|           hosts: Don't overwrite the hole file - Alejandro Colomar
* c5137b5 - Wed, 21 Apr 2021 14:14:34 +0200 (3 days ago) (tag: v0.6.2)
|           Makefile: ffix - Alejandro Colomar
alx@msi:~/src/alx/config$

Normally I would've run 'git rebase origin/main', but recently I knew about 'git pull --rebase', so I was tried it. However, to my surprise, it silently skipped the local commit:

alx@msi:~/src/alx/config$ git pull --rebase
Successfully rebased and updated refs/heads/main.
alx@msi:~/src/alx/config$ git tree -8
* 226e73c - Thu, 22 Apr 2021 22:28:37 +0200 (2 days ago) (HEAD -> main, 
tag: v0.8.0, origin/main, origin/HEAD)
|           Makefile: ffix - Alejandro Colomar
* 29cac15 - Thu, 22 Apr 2021 22:21:56 +0200 (2 days ago)
|           Makefile: remove unused option of read - Alejandro Colomar
* 5adc827 - Thu, 22 Apr 2021 22:20:16 +0200 (2 days ago)
|           Makefile: use INSTALL_DATA instead of plain install - 
Alejandro Colomar
* 28df09e - Thu, 22 Apr 2021 22:12:40 +0200 (2 days ago)
|           Makefile: Don't hardcode things - Alejandro Colomar
* 9cdb873 - Thu, 22 Apr 2021 22:11:32 +0200 (2 days ago)
|           ssh: Simplify code, and don't overwrite other contents of 
.ssh/config - Alejandro Colomar
* ad1d205 - Thu, 22 Apr 2021 12:51:10 +0200 (2 days ago) (tag: v0.7.0)
|           hosts: Don't overwrite the hole file - Alejandro Colomar
* c5137b5 - Wed, 21 Apr 2021 14:14:34 +0200 (3 days ago) (tag: v0.6.2)
|           Makefile: ffix - Alejandro Colomar
* 5244a5c - Wed, 21 Apr 2021 14:12:05 +0200 (3 days ago) (tag: v0.6.1)
|           sshd: restart service after installing - Alejandro Colomar
alx@msi:~/src/alx/config$
When trying 'git pull --rebase=interactive', I see the following:
noop 
 
# Rebase 4d2f5ad..4d2f5ad onto 226e73c (1 command)

I'd expect 'git pull --rebase' to be an equivalent of 'git fetch origin && git rebase origin/main'. But this time I had to use rebase:

alx@msi:~/src/alx/config$ git reset 4d2f --h
HEAD is now at 4d2f5ad sudo: Rename user alex to alx
alx@msi:~/src/alx/config$ git tree -8
* 226e73c - Thu, 22 Apr 2021 22:28:37 +0200 (2 days ago) (tag: v0.8.0, 
origin/main, origin/HEAD)
|           Makefile: ffix - Alejandro Colomar
* 29cac15 - Thu, 22 Apr 2021 22:21:56 +0200 (2 days ago)
|           Makefile: remove unused option of read - Alejandro Colomar
* 5adc827 - Thu, 22 Apr 2021 22:20:16 +0200 (2 days ago)
|           Makefile: use INSTALL_DATA instead of plain install - 
Alejandro Colomar
* 28df09e - Thu, 22 Apr 2021 22:12:40 +0200 (2 days ago)
|           Makefile: Don't hardcode things - Alejandro Colomar
* 9cdb873 - Thu, 22 Apr 2021 22:11:32 +0200 (2 days ago)
|           ssh: Simplify code, and don't overwrite other contents of 
.ssh/config - Alejandro Colomar
| * 4d2f5ad - Thu, 22 Apr 2021 19:22:16 +0200 (2 days ago) (HEAD -> main)
|/            sudo: Rename user alex to alx - Alejandro Colomar
* ad1d205 - Thu, 22 Apr 2021 12:51:10 +0200 (2 days ago) (tag: v0.7.0)
|           hosts: Don't overwrite the hole file - Alejandro Colomar
* c5137b5 - Wed, 21 Apr 2021 14:14:34 +0200 (3 days ago) (tag: v0.6.2)
|           Makefile: ffix - Alejandro Colomar
alx@msi:~/src/alx/config$ git rebase origin/main
Successfully rebased and updated refs/heads/main.
alx@msi:~/src/alx/config$ git tree -8
* 72f6ab9 - Thu, 22 Apr 2021 19:22:16 +0200 (2 days ago) (HEAD -> main)
|           sudo: Rename user alex to alx - Alejandro Colomar
* 226e73c - Thu, 22 Apr 2021 22:28:37 +0200 (2 days ago) (tag: v0.8.0, 
origin/main, origin/HEAD)
|           Makefile: ffix - Alejandro Colomar
* 29cac15 - Thu, 22 Apr 2021 22:21:56 +0200 (2 days ago)
|           Makefile: remove unused option of read - Alejandro Colomar
* 5adc827 - Thu, 22 Apr 2021 22:20:16 +0200 (2 days ago)
|           Makefile: use INSTALL_DATA instead of plain install - 
Alejandro Colomar
* 28df09e - Thu, 22 Apr 2021 22:12:40 +0200 (2 days ago)
|           Makefile: Don't hardcode things - Alejandro Colomar
* 9cdb873 - Thu, 22 Apr 2021 22:11:32 +0200 (2 days ago)
|           ssh: Simplify code, and don't overwrite other contents of 
.ssh/config - Alejandro Colomar
* ad1d205 - Thu, 22 Apr 2021 12:51:10 +0200 (2 days ago) (tag: v0.7.0)
|           hosts: Don't overwrite the hole file - Alejandro Colomar
* c5137b5 - Wed, 21 Apr 2021 14:14:34 +0200 (3 days ago) (tag: v0.6.2)
|           Makefile: ffix - Alejandro Colomar
alx@msi:~/src/alx/config$
I wonder if it may be due to this text, which I don't really understand:
alx@msi:~$ man git-pull | sed -n '/-r, --rebase/,/^$/p'
        -r, --rebase[=false|true|merges|preserve|interactive]
            When true, rebase the current branch on top of the
            upstream branch after fetching. If there is a
            remote-tracking branch corresponding to the upstream
            branch and the upstream branch was rebased since last
            fetched, the rebase uses that information to avoid
            rebasing non-local changes.

What does it mean "the upstream branch was rebased since last fetched"? May it be the reason that it skipped that commit? Isn't 'git pull --rebase' designed for what I'm using it? In this case it's not really necessary, but it removes the need for specifying the branch I'm on, which is why I preferred it over 'git rebase'.

Thanks,
Alex
-- 
Alejandro Colomar
Linux man-pages comaintainer; https://www.kernel.org/doc/man-pages/
Senior SW Engineer; http://www.alejandro-colomar.es/

← back to recent threads