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

2.43+ git checkout --theirs on stash error - no alternative?

From
DDDevste Devste <devstemail@gmail.com>
Date
Oct 27, 2024, 22:16 UTC
Message-ID
<CANM0SV0KKd+WN4MQ1_8fEvFyD4tYY3qAUsUh9Njcy1xo1hNSBw@mail.gmail.com>

What did you do before the bug happened? (Steps to reproduce your issue) git checkout 'stash@{0}' --theirs -- "some-file.txt"

What did you expect to happen? (Expected behavior) Checking out the file exactly as it is in the stash with any conflicts resolved using the stash's data

What happened instead? (Actual behavior) fatal: '--merge', '--ours', or '--theirs' cannot be used when checking out of a tree

What's different between what you expected and what actually happened? Error and unresolved conflicts

Anything else you want to add: This behavior was changed in 2.43 https://www.spinics.net/lists/git/msg463600.html However, I think this change is wrong. Since using --theirs still makes sense, if you want to restore a file to the exact state it was in the stash. While the change probably had in mind that this should be used: git cherry-pick --no-commit --mainline 1 --strategy-option=theirs 'stash@{0}' This leads to different results than git checkout --theirs, since it tries to resolve the conflicts and is not correctly using "theirs" to automatically resolve them How can the pre 2.43 behavior be achieved?

Please review the rest of the bug report below. You can delete any lines you don't wish to share.

[System Info] git version: git version 2.43.5 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh uname: Linux 5.14.0-162.23.1.el9_1.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Apr 11 19:09:37 UTC 2023 x86_64 compiler info: gnuc: 11.4 libc info: glibc: 2.34 $SHELL (typically, interactive shell): /bin/bash

[Enabled Hooks]
Next: Devste Devste
Message 1 of 6 in “2.43+ git checkout --theirs on stash error - no alternative?”
  1. Devste DevsteOct 27, 2024
  2. Devste DevsteOct 27, 2024
  3. Taylor BlauOct 27, 2024
  4. Devste DevsteNov 4, 2024
  5. Junio C HamanoNov 4, 2024
  6. Devste DevsteNov 6, 2024

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.