git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Possible git bug

From
WSWesley Schwengle <wesley@schwengle.net>
Date
Sep 16, 2021, 03:29 UTC
Message-ID
<30651e4d-10fb-8bc7-7f52-8fbabf042f4a@schwengle.net>
Hello,

I'm running into a weird issue with git at the moment and I'm wondering if this is a bug. I have a small reproduction path:

$ mkdir reproduction $ cd reproduction $ git init . $ echo "commit a" > file.txt $ git commit -m "First commit" file.txt $ echo "commit b" >> file.txt $ git commit -m "Second commit" file.txt

$ git switch -c foo $ echo "commit c" >> file.txt" $ git commit -m "Third commit" file.txt $ git branch --set-upstream-to=master

$ git status On branch foo Your branch is ahead of 'master' by 1 commit.

$ git switch master $ git merge foo $ git reset --hard HEAD^ $ git switch foo Switched to branch 'foo' Your branch is ahead of 'master' by 1 commit.

$ git log --format='%C(yellow)%h%Creset %Cgreen%s%Creset' 5f427e3 Third commit 03ad791 Second commit 411e6d4 First commit

$ git rebase master $ git status On branch foo Your branch is up to date with 'master'.

$ git log --format='%C(yellow)%h%Creset %Cgreen%s%Creset' 03ad791 Second commit 411e6d4 First commit

I do not expect to lose the commits from foo, it seems the ref of master doesn't get updated after a reset.

I didn't lose any work because I pushed my work to a remote and can still get it from there (and git reflog would also reach my code). It is rather surprising to see this kind of behavior.

I'm running: $ git --version git version 2.33.0.363.g4c719308ce

But I also got this behavior with the git shipped with Debian: $ /usr/bin/git --version git version 2.32.0

Cheers, Wesley

-- 
Wesley Schwengle
E: wesley@schwengle.net
Next: Taylor Blau
Message 1 of 20 in “Possible git bug”
  1. Wesley SchwengleSep 16, 2021
  2. Taylor BlauSep 16, 2021
  3. Wesley SchwengleSep 16, 2021
  4. wesley@schwengle.netSep 16, 2021
  5. Document `rebase.forkpoint` in rebase man pagewesley@schwengle.net, Sep 16, 2021
  6. Junio C HamanoSep 16, 2021
  7. Junio C HamanoSep 16, 2021
  8. wesley@schwengle.netSep 16, 2021
  9. Document `rebase.forkpoint` in rebase man pagewesley@schwengle.net, Sep 16, 2021
  10. Junio C HamanoSep 16, 2021
  11. Wesley SchwengleSep 16, 2021
  12. Junio C HamanoSep 16, 2021
  13. Wesley SchwengleSep 20, 2021
  14. wesley@schwengle.netSep 16, 2021
  15. Document `rebase.forkpoint` in rebase man pagewesley@schwengle.net, Sep 16, 2021
  16. Junio C HamanoSep 20, 2021
  17. Junio C HamanoSep 16, 2021
  18. Wesley SchwengleSep 16, 2021
  19. Junio C HamanoSep 16, 2021
  20. Wesley SchwengleSep 16, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.