Git Mailing List Archive mirror
 help / color / mirror / Atom feed
From: i o <lvsil4@outlook.com>
To: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: Proposal: adding --soft and --mixed options to git checkout
Date: Mon, 24 Apr 2023 11:41:47 +0000	[thread overview]
Message-ID: <PA4PR09MB65161C38AEFBC07B3D7A1C62B0679@PA4PR09MB6516.eurprd09.prod.outlook.com> (raw)

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.

             reply	other threads:[~2023-04-24 11:41 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-24 11:41 i o [this message]
2023-04-24 21:32 ` Proposal: adding --soft and --mixed options to git checkout Felipe Contreras
2023-04-25  9:28   ` i o
2023-04-27 21:10     ` Felipe Contreras

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=PA4PR09MB65161C38AEFBC07B3D7A1C62B0679@PA4PR09MB6516.eurprd09.prod.outlook.com \
    --to=lvsil4@outlook.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).