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

Proposal: adding --soft and --mixed options to git checkout

From
IOi o <lvsil4@outlook.com>
Date
Apr 24, 2023, 11:41 UTC
Message-ID
<PA4PR09MB65161C38AEFBC07B3D7A1C62B0679@PA4PR09MB6516.eurprd09.prod.outlook.com>
I suggest adding `--soft` and `--mixed` options to `git checkout`, that act similarly to the corresponding options of `git reset`, i.e. `git checkout --soft <tree-ish>` should move the HEAD to <tree-ish> without affecting the working tree or index, and `git checkout --mixed <tree-ish>` should move the HEAD to <tree-ish> and update the index to match it without changing the working tree.
The difference between this and `git reset` of course would be that, unlike the latter, this doesn't 'drag' the current branch along with HEAD; instead the usual behaviour would apply depending on what exactly <tree-ish> is, i.e. `git checkout [--soft|--mixed] <commit>` would detach HEAD and point it to <commit>, whereas `git checkout [--soft|--mixed] <branch>` would move HEAD and switch from the current branch to <branch>.
I'm aware work arounds exist for these, something like:
    ```
    git checkout --detach
    git reset [--soft|--mixed] [<branch>|<commit>]
    git checkout [<branch>|<commit>]
    ```
so the aim here is really one of convenience by having this feature contained in a native option.
Another option that might be worth adding to `git checkout` is `--keep-index` (like the option in `git stash`), to move the HEAD to <tree-ish> and update the working tree to match it without changing the index.
Next: Felipe Contreras
Message 1 of 4 in “Proposal: adding --soft and --mixed options to git checkout”
  1. i oApr 24, 2023
  2. Felipe ContrerasApr 24, 2023
  3. i oApr 25, 2023
  4. Felipe ContrerasApr 27, 2023

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.