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

Re: [PATCH 0/2] push: fix --force-if-includes consulting wrong ref

From
Ben Knoble <ben.knoble@gmail.com>
Date
Sep 5, 2026, 18:59 UTC
Message-ID
<D798198C-5F97-4701-9050-7868B6482214@gmail.com>
In-Reply-To
<20260904210122.431757-1-tyler@tylercipriani.com>
Show 11 quoted lines
> Le 4 sept. 2026 à 17:01, Tyler Cipriani <tyler@tylercipriani.com> a écrit :
> 
> --force-if-includes has been checking the reflog of the local branch named
> after the destination branch regardless of what's being pushed. This can cause
> false rejections or unintended data loss.
> 
> False rejection has been reported twice that I could find:
> 
> - 2023-07-26 - Stefan Haller reported local branch with a different name
>              false rejection[0]
> - 2025-05-08 - D. Ben Knoble reported detached HEAD false rejection[1]

Aha. I’d nearly forgotten that mail, and have since adjusted to some intuition of when to force-if-includes.

I’d be grateful to not need such potentially-buggy intuition :)
Show 31 quoted lines
> The same root cause can result in data loss: when a same-name local branch
> contains the remote tip but you --force-if-includes push an unrelated branch,
> clobbering the remote repo. PoCs are in t/t5533-push-cas.sh -- new test cases
> fail against maint, but pass with patches applied.
> 
> Existing tests covered refspecs with different names for --force-with-lease,
> but missed --force-if-includes. New patches cover:
> 
> - allow forced-update using refspec with different-named local branch
> - allow same as above, but with HEAD
> - reject force-update using refspec with different-named local branch lacking
> branch tip
> - reject same as above using HEAD
> - reject detached HEAD
> 
> Open question: the detached HEAD case. I opted to reject, since it seems like
> it might be surprising to allow in the case where you were just on a branch
> without the the tip of a remote ref, removed the last commit with git checkout
> HEAD^ and pushed with --force-if-includes and it allowed a destructive push.
> I made a separate patch showing different advice for that case (since a
> git pull won't help).
> 
> Based on maint since this is a bugfix. Happy to split patches any way
> that's helpful.
> 
> [0]: <https://lore.kernel.org/git/f51c73ed-eb03-83ca-fb31-d3e2645c9a63@haller-berlin.de>
> [1]: <https://lore.kernel.org/git/CALnO6CCk0SgwObQRnpd5Pt_DvCKF8dBmyVHivU6Nr_O-GusGLA@mail.gmail.com>
> 
> Tyler Cipriani (2):
> push: check pushed ref for --force-if-includes
> push: fix --force-if-includes detached HEAD advice

Thanks for the advice changes! One small nit on the first patch you can ignore if you choose.

At first I hoped we might be able to stop rejecting detached HEAD pushes, but some further thought begs the question: what reflog would we use? HEAD’s is too broad :)

So this may be all we can do for now.
At least I can replace my intuition with reading the error message again. 
Previous: Tyler CiprianiNext: Tyler Cipriani
Message 5 of 40 in “push: fix --force-if-includes consulting wrong ref”
  1. 0/2 push: fix --force-if-includes consulting wrong refTyler Cipriani, Sep 4, 2026
  2. 1/2 push: check pushed ref for --force-if-includesTyler Cipriani, Sep 4, 2026
  3. Ben KnobleSep 5, 2026
  4. 2/2 push: fix --force-if-includes detached HEAD adviceTyler Cipriani, Sep 4, 2026
  5. Ben KnobleSep 5, 2026
  6. Tyler CiprianiSep 6, 2026
  7. 0/2 push: fix --force-if-includes consulting wrong refTyler Cipriani, Sep 8, 2026
  8. D. Ben KnobleSep 9, 2026
  9. 1/2 push: check pushed ref for --force-if-includesTyler Cipriani, Sep 8, 2026
  10. Junio C HamanoSep 10, 2026
  11. Tyler CiprianiSep 10, 2026
  12. 2/2 push: fix --force-if-includes detached HEAD adviceTyler Cipriani, Sep 8, 2026
  13. 0/2 push: fix --force-if-includes consulting wrong refTyler Cipriani, Sep 10, 2026
  14. 1/2 push: check pushed ref for --force-if-includesTyler Cipriani, Sep 10, 2026
  15. Patrick SteinhardtSep 11, 2026
  16. Tyler CiprianiSep 11, 2026
  17. Junio C HamanoSep 11, 2026
  18. Tyler CiprianiSep 11, 2026
  19. 2/2 push: fix --force-if-includes detached HEAD adviceTyler Cipriani, Sep 10, 2026
  20. Patrick SteinhardtSep 11, 2026
  21. Junio C HamanoSep 11, 2026
  22. Junio C HamanoSep 11, 2026
  23. 0/2 push: check pushed ref for --force-if-includesTyler Cipriani, Sep 14, 2026
  24. 1/2 push: check pushed ref for --force-if-includesTyler Cipriani, Sep 14, 2026
  25. 2/2 push: fix --force-if-includes non-branch adviceTyler Cipriani, Sep 14, 2026
  26. D. Ben KnobleSep 14, 2026
  27. Tyler CiprianiSep 14, 2026
  28. D. Ben KnobleSep 14, 2026
  29. 0/3 push: check pushed ref for --force-if-includesTyler Cipriani, Sep 15, 2026
  30. 1/3 push: check pushed ref for --force-if-includesTyler Cipriani, Sep 15, 2026
  31. 2/3 push: fix --force-if-includes non-branch adviceTyler Cipriani, Sep 15, 2026
  32. 3/3 push: --force-if-includes should allow fast-forwardTyler Cipriani, Sep 15, 2026
  33. D. Ben KnobleSep 16, 2026
  34. Tyler CiprianiSep 16, 2026
  35. Ben KnobleSep 16, 2026
  36. 0/3 push: check pushed ref for --force-if-includesTyler Cipriani, Sep 17, 2026
  37. 1/3 push: check pushed ref for --force-if-includesTyler Cipriani, Sep 17, 2026
  38. 2/3 push: fix --force-if-includes non-branch adviceTyler Cipriani, Sep 17, 2026
  39. 3/3 push: --force-if-includes should allow fast-forwardTyler Cipriani, Sep 17, 2026
  40. Tyler CiprianiOct 5, 2026

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.