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

[PATCH v5 00/26] Add new command 'switch'

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Mar 21, 2019, 13:16 UTC
Message-ID
<20190321131655.15249-1-pclouds@gmail.com>
In-Reply-To
<20190317124926.17137-1-pclouds@gmail.com>

This adds a new command 'git-switch' as the half-replacement for 'git-checkout'. Jump to 12/26 as the starting point. The other half is git-restore, which is dealt with separately.

The diff delta is shrinking nicely. The two main changes are
- '--orphan <new-branch> <initial-tree>' is no longer accepted
- --force implies --ignore-in-progress
The rest is the usual typo and bug fixes.

The two "todo" items from v4 will be handled separately and will not be mentioned again in v6 (if there is one):

 - The 'checkout -m' losing staged changes problem has already been
discussed elsewhere and I'm still trying to see if I can improve it.
 - I have some work in progress for improving tracking branch error
message, but it's unlikely to conflict badly with this series.
Nguyễn Thái Ngọc Duy (26):
  git-checkout.txt: spell out --no-option
  git-checkout.txt: fix one syntax line
  doc: document --overwrite-ignore
  git-checkout.txt: fix monospace typeset
  t: rename t2014-switch.sh to t2014-checkout-switch.sh
  checkout: advice how to get out of detached HEAD mode
  checkout: keep most #include sorted
  checkout: factor out some code in parse_branchname_arg()
  checkout: make "opts" in cmd_checkout() a pointer
  checkout: move 'confict_style' and 'dwim_..' to checkout_opts
  checkout: split options[] array in three pieces
  checkout: split part of it to new command 'switch'
  switch: better names for -b and -B
  switch: add --discard-changes
  switch: remove -l
  switch: stop accepting pathspec
  switch: reject "do nothing" case
  switch: only allow explicit detached HEAD
  switch: add short option for --detach
  switch: implicit dwim, use --no-guess to disable it
  switch: no worktree status unless real branch switch happens
  switch: reject if some operation is in progress
  switch: make --orphan switch to an empty tree
  t: add tests for switch
  completion: support switch
  doc: promote "git switch"
 .gitignore                                    |   1 +
 Documentation/config/advice.txt               |  13 +-
 Documentation/config/branch.txt               |   4 +-
 Documentation/config/checkout.txt             |  17 +-
 Documentation/config/diff.txt                 |   3 +-
 Documentation/git-branch.txt                  |  12 +-
 Documentation/git-check-ref-format.txt        |   3 +-
 Documentation/git-checkout.txt                | 221 ++++---
 Documentation/git-format-patch.txt            |   2 +-
 Documentation/git-merge-base.txt              |   2 +-
 Documentation/git-merge.txt                   |   5 +
 Documentation/git-rebase.txt                  |   2 +-
 Documentation/git-remote.txt                  |   2 +-
 Documentation/git-rerere.txt                  |  10 +-
 Documentation/git-reset.txt                   |  20 +-
 Documentation/git-stash.txt                   |   9 +-
 Documentation/git-switch.txt (new)            | 276 ++++++++
 Documentation/gitattributes.txt               |   3 +-
 Documentation/gitcore-tutorial.txt            |  19 +-
 Documentation/giteveryday.txt                 |  24 +-
 Documentation/githooks.txt                    |   8 +-
 Documentation/gittutorial.txt                 |   4 +-
 Documentation/gitworkflows.txt                |   3 +-
 Documentation/revisions.txt                   |   2 +-
 Documentation/user-manual.txt                 |  56 +-
 Makefile                                      |   1 +
 advice.c                                      |  17 +-
 builtin.h                                     |   1 +
 builtin/checkout.c                            | 605 ++++++++++--------
 command-list.txt                              |   1 +
 contrib/completion/git-completion.bash        |  37 +-
 git.c                                         |   1 +
 parse-options-cb.c                            |  17 +
 parse-options.h                               |   1 +
 sha1-name.c                                   |   2 +-
 t/t1090-sparse-checkout-scope.sh              |  14 -
 ...014-switch.sh => t2014-checkout-switch.sh} |   0
 t/t2020-checkout-detach.sh                    |  28 +-
 t/t2060-switch.sh (new +x)                    |  98 +++
 39 files changed, 1051 insertions(+), 493 deletions(-)
 create mode 100644 Documentation/git-switch.txt
 rename t/{t2014-switch.sh => t2014-checkout-switch.sh} (100%)
 create mode 100755 t/t2060-switch.sh
Range-diff dựa trên v4:
 1:  535dc1f310 !  1:  7bcb4b0ff8 doc: document --overwrite-ignore
    @@ -22,20 +22,7 @@
     +
      --recurse-submodules::
      --no-recurse-submodules::
    --	Using --recurse-submodules will update the content of all initialized
    -+	Using `--recurse-submodules` will update the content of all initialized
    - 	submodules according to the commit recorded in the superproject. If
    - 	local modifications in a submodule would be overwritten the checkout
    --	will fail unless `-f` is used. If nothing (or --no-recurse-submodules)
    -+	will fail unless `-f` is used. If nothing (or `--no-recurse-submodules`)
    - 	is used, the work trees of submodules will not be updated.
    --	Just like linkgit:git-submodule[1], this will detach the
    --	submodules HEAD.
    -+	Just like linkgit:git-submodule[1], this will detach `HEAD` of the
    -+	submodule.
    - 
    - --no-guess::
    - 	Do not attempt to create a branch if a remote tracking branch
    + 	Using --recurse-submodules will update the content of all initialized
     
      diff --git a/Documentation/git-merge.txt b/Documentation/git-merge.txt
      --- a/Documentation/git-merge.txt
 2:  b6305d2871 !  2:  f2d77152eb git-checkout.txt: fix monospace typeset
    @@ -4,8 +4,7 @@
     
         Add backticks where we have none, replace single quotes with backticks
         and replace double-quotes. Drop double-quotes from nested constructions
    -    such as `"@{-1}"`. Add a missing possessive apostrophe after the word
    -    "submodules" while at it.
    +    such as `"@{-1}"`.
     
         Helped-by: Martin Ågren <martin.agren@gmail.com>
         Signed-off-by: Martin Ågren <martin.agren@gmail.com>
    @@ -207,6 +206,24 @@
      This means that you can use `git checkout -p` to selectively discard
      edits from your current working tree. See the ``Interactive Mode''
     @@
    + 
    + --recurse-submodules::
    + --no-recurse-submodules::
    +-	Using --recurse-submodules will update the content of all initialized
    ++	Using `--recurse-submodules` will update the content of all initialized
    + 	submodules according to the commit recorded in the superproject. If
    + 	local modifications in a submodule would be overwritten the checkout
    +-	will fail unless `-f` is used. If nothing (or --no-recurse-submodules)
    ++	will fail unless `-f` is used. If nothing (or `--no-recurse-submodules`)
    + 	is used, the work trees of submodules will not be updated.
    +-	Just like linkgit:git-submodule[1], this will detach the
    +-	submodules HEAD.
    ++	Just like linkgit:git-submodule[1], this will detach `HEAD` of the
    ++	submodule.
    + 
    + --no-guess::
    + 	Do not attempt to create a branch if a remote tracking branch
    +@@
      	In the default overlay mode, `git checkout` never
      	removes files from the index or the working tree.  When
      	specifying `--no-overlay`, files that appear in the index and
 3:  bb56e45457 =  3:  cbe630fb4a t: rename t2014-switch.sh to t2014-checkout-switch.sh
 4:  123392757a =  4:  6bc8a1052f checkout: advice how to get out of detached HEAD mode
 5:  d1ec6b4ce0 =  5:  0bb2aefb85 checkout: keep most #include sorted
 6:  4b1742672b =  6:  ace82aa26f checkout: factor out some code in parse_branchname_arg()
 7:  e0bcc3a4dd =  7:  6e13efcba8 checkout: make "opts" in cmd_checkout() a pointer
 8:  ca5b4d7db0 =  8:  f61a042eb8 checkout: move 'confict_style' and 'dwim_..' to checkout_opts
 9:  13c03997f0 =  9:  972cebc568 checkout: split options[] array in three pieces
10:  24d532b276 ! 10:  970c727b24 checkout: split part of it to new command 'switch'
    @@ -147,9 +147,10 @@
     +SYNOPSIS
     +--------
     +[verse]
    -+'git switch' [<options>] [--guess] <branch>
    ++'git switch' [<options>] [--no-guess] <branch>
     +'git switch' [<options>] --detach [<start-point>]
    -+'git switch' [<options>] (-c|-C|--orphan) <new-branch> [<start-point>]
    ++'git switch' [<options>] (-c|-C) <new-branch> [<start-point>]
    ++'git switch' [<options>] --orphan <new-branch>
     +
     +DESCRIPTION
     +-----------
    @@ -164,8 +165,8 @@
     +
     +Switching branches does not require a clean index and working tree
     +(i.e. no differences compared to `HEAD`). The operation is aborted
    -+however if the switch leads to loss of local changes, unless told
    -+otherwise.
    ++however if the operation leads to loss of local changes, unless told
    ++otherwise with `--discard-changes` or `--merge`.
     +
     +OPTIONS
     +-------
    @@ -183,7 +184,7 @@
     +	from some other point.)
     ++
     +You can use the `@{-N}` syntax to refer to the N-th last
    -+branch/commit switched to "git switch" or "git checkout"
    ++branch/commit switched to using "git switch" or "git checkout"
     +operation. You may also specify `-` which is synonymous to `@{-1}`.
     +This is often used to switch quickly between two branches, or to undo
     +a branch switch by mistake.
    @@ -242,7 +243,7 @@
     +
     +-f::
     +--force::
    -+	An alias for `--discard-changes`.
    ++	An alias for `--discard-changes` and `--ignore-in-progress`.
     +
     +--discard-changes::
     +	Proceed even if the index or the working tree differs from
    @@ -250,6 +251,11 @@
     +	the switching target. This is used to throw away local
     +	changes.
     +
    ++--ignore-in-progress::
    ++	`git switch` by default refuses when some operation is in
    ++	progress (e.g. "git rebase", "git am" ...). This option
    ++	overrides this safety check and allows switching.
    ++
     +-m::
     +--merge::
     +	If you have local modifications to one or more files that are
    @@ -304,10 +310,8 @@
     +	`branch.autoSetupMerge` configuration variable is true.
     +
     +--orphan <new-branch>::
    -+	Create a new 'orphan' branch, named `<new-branch>`. If
    -+	`<start-point>` is specified, the index and working tree are
    -+	adjusted to match it. Otherwise both are adjusted to contain no
    -+	tracked files.
    ++	Create a new 'orphan' branch, named `<new-branch>`. All
    ++	tracked files are removed.
     +
     +--ignore-other-worktrees::
     +	`git switch` refuses when the wanted ref is already
    @@ -315,11 +319,6 @@
     +	the ref out anyway. In other words, the ref can be held by
     +	more than one worktree.
     +
    -+--ignore-in-progress::
    -+	`git switch` by default refuses when some operation is in
    -+	progress (e.g. "git rebase", "git am" ...). This option
    -+	overrides this safety check and allows switching.
    -+
     +--recurse-submodules::
     +--no-recurse-submodules::
     +	Using `--recurse-submodules` will update the content of all initialized
11:  c966bacfcc = 11:  676f5df0fd switch: better names for -b and -B
12:  bdb88bf9a9 ! 12:  4e37c0659e switch: add --discard-changes
    @@ -4,8 +4,8 @@
     
         --discard-changes is a better name than --force for this option since
         it's what really happens. --force is turned to an alias for
    -    --discard-changes. But it's meant to an alias for potentially more force
    -    options in the future.
    +    --discard-changes. But it's meant to be an alias for potentially more
    +    force options in the future.
     
      diff --git a/builtin/checkout.c b/builtin/checkout.c
      --- a/builtin/checkout.c
13:  d5fe7f4bd0 = 13:  a57208d137 switch: remove -l
14:  3bce4c521e = 14:  3de6f95bf2 switch: stop accepting pathspec
15:  dad0063fc4 = 15:  ad225517cd switch: reject "do nothing" case
16:  41ca042917 = 16:  583cfd5cc4 switch: only allow explicit detached HEAD
17:  a0b9f1b285 = 17:  1c5aee658d switch: add short option for --detach
18:  3d254df104 = 18:  d942ac52e2 switch: implicit dwim, use --no-guess to disable it
19:  c6ea203f36 = 19:  37eb152c0d switch: no worktree status unless real branch switch happens
20:  5c4effc7fd ! 20:  50d6768afd switch: reject if some operation is in progress
    @@ -12,6 +12,9 @@
         that separate thing you want to work on and leave this worktree
         alone (unless of course creating or preparing worktrees are not cheap).
     
    +    --force is updated to also imply --ignore-in-progress because it is
    +    supposed to be the "just do your things and don't bother me" option.
    +
      diff --git a/builtin/checkout.c b/builtin/checkout.c
      --- a/builtin/checkout.c
      +++ b/builtin/checkout.c
    @@ -45,7 +48,7 @@
     +			die(_("cannot switch branch while merging"));
     +		if (state.am_in_progress)
     +			die(_("cannot switch branch in the middle of an am session"));
    -+		if (state.rebase_in_progress || state.rebase_in_progress)
    ++		if (state.rebase_interactive_in_progress || state.rebase_in_progress)
     +			die(_("cannot switch branch while rebasing"));
     +		if (state.cherry_pick_in_progress)
     +			die(_("cannot switch branch while cherry-picking"));
    @@ -58,6 +61,18 @@
      	if (new_branch_info->path && !opts->force_detach && !opts->new_branch &&
      	    !opts->ignore_other_worktrees) {
      		int flag;
    +@@
    + 		opts->merge = 1; /* implied */
    + 		git_xmerge_config("merge.conflictstyle", opts->conflict_style, NULL);
    + 	}
    +-	if (opts->force)
    ++	if (opts->force) {
    + 		opts->discard_changes = 1;
    ++		opts->can_switch_when_in_progress = 1;
    ++	}
    + 
    + 	if ((!!opts->new_branch + !!opts->new_branch_force + !!opts->new_orphan_branch) > 1)
    + 		die(_("-b, -B and --orphan are mutually exclusive"));
     @@
      	opts.only_merge_on_switching_branches = 0;
      	opts.accept_pathspec = 1;
21:  a4afe6a999 ! 21:  af8bb710c8 switch: --orphan defaults to empty tree as HEAD
    @@ -1,15 +1,16 @@
     Author: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
     
    -    switch: --orphan defaults to empty tree as HEAD
    +    switch: make --orphan switch to an empty tree
     
         Switching and creating branches always involves knowing the
         <start-point> to begin the new branch from. Sometimes, people want to
         create a new branch that does not have any commits yet; --orphan is a
         flag to allow that.
     
    -    If <start-point> is not specified, instead of leaving index/worktree
    -    unchanged, default to "empty tree" starting point, allowing a clean
    -    start.
    +    --orphan overrides the default of HEAD for <start-point> instead causing
    +    us to start from an empty history with all tracked files removed from
    +    the index and working tree. The use of --orphan is incompatible with
    +    specifying a <start-point>.
     
         A note on the implementation. An alternative is just create a dummy
         commit in-core with empty tree and switch to it. But there's a chance
    @@ -23,7 +24,7 @@
      	int switch_branch_doing_nothing_is_ok;
      	int only_merge_on_switching_branches;
      	int can_switch_when_in_progress;
    -+	int orphan_default_empty_tree;
    ++	int orphan_from_empty_tree;
      
      	const char *new_branch;
      	const char *new_branch_force;
    @@ -38,9 +39,11 @@
      		return error(_("index file corrupt"));
      
      	resolve_undo_clear();
    -+	if (opts->orphan_default_empty_tree && !new_branch_info->commit)
    ++	if (opts->new_orphan_branch && opts->orphan_from_empty_tree) {
    ++		if (new_branch_info->commit)
    ++			BUG("'switch --orphan' should never accept a commit as starting point");
     +		new_tree = parse_tree_indirect(the_hash_algo->empty_tree);
    -+	else
    ++	} else
     +		new_tree = get_commit_tree(new_branch_info->commit);
      	if (opts->discard_changes) {
     -		ret = reset_tree(get_commit_tree(new_branch_info->commit),
    @@ -106,23 +109,34 @@
      	if (prepare_revision_walk(&revs))
      		die(_("internal error in revision walk"));
     @@
    + 	if (old_branch_info.path)
    + 		skip_prefix(old_branch_info.path, "refs/heads/", &old_branch_info.name);
      
    - 		if (opts->only_merge_on_switching_branches)
    - 			do_merge = 0;
    ++	if (opts->new_orphan_branch && opts->orphan_from_empty_tree) {
    ++		if (new_branch_info->name)
    ++			BUG("'switch --orphan' should never accept a commit as starting point");
    ++		new_branch_info->commit = NULL;
    ++		new_branch_info->name = "(empty)";
    ++		do_merge = 1;
    ++	}
     +
    -+		if (opts->new_orphan_branch && opts->orphan_default_empty_tree) {
    -+			new_branch_info->commit = NULL;
    -+			new_branch_info->name = "(empty)";
    -+			do_merge = 1;
    -+		}
    - 	}
    - 
    - 	if (do_merge) {
    + 	if (!new_branch_info->name) {
    + 		new_branch_info->name = "HEAD";
    + 		new_branch_info->commit = old_branch_info.commit;
    +@@
    + 	if (opts->new_orphan_branch) {
    + 		if (opts->track != BRANCH_TRACK_UNSPECIFIED)
    + 			die(_("'%s' cannot be used with '%s'"), "--orphan", "-t");
    ++		if (opts->orphan_from_empty_tree && new_branch_info->name)
    ++			die(_("'%s' cannot take <start-point>"), "--orphan");
    + 	} else if (opts->force_detach) {
    + 		if (opts->track != BRANCH_TRACK_UNSPECIFIED)
    + 			die(_("'%s' cannot be used with '%s'"), "--detach", "-t");
     @@
      	opts.accept_pathspec = 1;
      	opts.implicit_detach = 1;
      	opts.can_switch_when_in_progress = 1;
    -+	opts.orphan_default_empty_tree = 0;
    ++	opts.orphan_from_empty_tree = 0;
      
      	options = parse_options_dup(checkout_options);
      	options = add_common_options(&opts, options);
    @@ -130,7 +144,7 @@
      	opts.only_merge_on_switching_branches = 1;
      	opts.implicit_detach = 0;
      	opts.can_switch_when_in_progress = 0;
    -+	opts.orphan_default_empty_tree = 1;
    ++	opts.orphan_from_empty_tree = 1;
      
      	options = parse_options_dup(switch_options);
      	options = add_common_options(&opts, options);
22:  6cca78f835 ! 22:  4a293a3d53 t: add tests for switch
    @@ -67,6 +67,7 @@
     +
     +test_expect_success 'new orphan branch from empty' '
     +	test_when_finished git switch master &&
    ++	test_must_fail git switch --orphan new-orphan HEAD &&
     +	git switch --orphan new-orphan &&
     +	test_commit orphan &&
     +	git cat-file commit refs/heads/new-orphan >commit &&
23:  e5e6f9d6f1 = 23:  b10290b378 completion: support switch
24:  807e8bc50b = 24:  67c5175e5f doc: promote "git switch"
-- 
2.21.0.548.gd3c7d92dc2
Previous: Junio C HamanoNext: Nguyễn Thái Ngọc Duy
Message 217 of 289 in “Add new command "switch"”
  1. 00/19 Add new command "switch"Nguyễn Thái Ngọc Duy, Jan 30, 2019
  2. 01/19 git-checkout.txt: fix one syntax lineNguyễn Thái Ngọc Duy, Jan 30, 2019
  3. 02/19 doc: document --overwrite-ignoreNguyễn Thái Ngọc Duy, Jan 30, 2019
  4. 03/19 t: rename t2014-switch.sh to t2014-checkout-switch.shNguyễn Thái Ngọc Duy, Jan 30, 2019
  5. 04/19 checkout: factor out some code in parse_branchname_arg()Nguyễn Thái Ngọc Duy, Jan 30, 2019
  6. 05/19 checkout: make "opts" in cmd_checkout() a pointerNguyễn Thái Ngọc Duy, Jan 30, 2019
  7. 06/19 checkout: move 'confict_style' and 'dwim_..' to checkout_optsNguyễn Thái Ngọc Duy, Jan 30, 2019
  8. 07/19 checkout: split options[] array in three piecesNguyễn Thái Ngọc Duy, Jan 30, 2019
  9. 08/19 checkout: split part of it to new command switchNguyễn Thái Ngọc Duy, Jan 30, 2019
  10. Eric SunshineJan 31, 2019
  11. Duy NguyenJan 31, 2019
  12. Eric SunshineJan 31, 2019
  13. Eric SunshineJan 31, 2019
  14. Duy NguyenJan 31, 2019
  15. Eric SunshineJan 31, 2019
  16. git-commit.txt: better description what it doesNguyễn Thái Ngọc Duy, Jan 31, 2019
  17. Eric SunshineJan 31, 2019
  18. Duy NguyenJan 31, 2019
  19. Eric SunshineFeb 1, 2019
  20. git-commit.txt: better description what it doesNguyễn Thái Ngọc Duy, Feb 1, 2019
  21. Junio C HamanoFeb 4, 2019
  22. SZEDER GáborJan 31, 2019
  23. SZEDER GáborJan 31, 2019
  24. Duy NguyenFeb 8, 2019
  25. 09/19 switch: better names for -b and -BNguyễn Thái Ngọc Duy, Jan 30, 2019
  26. Eric SunshineJan 31, 2019
  27. 10/19 switch: remove -lNguyễn Thái Ngọc Duy, Jan 30, 2019
  28. 11/19 switch: stop accepting pathspecNguyễn Thái Ngọc Duy, Jan 30, 2019
  29. 12/19 switch: reject "do nothing" caseNguyễn Thái Ngọc Duy, Jan 30, 2019
  30. 13/19 switch: only allow explicit detached HEADNguyễn Thái Ngọc Duy, Jan 30, 2019
  31. 14/19 switch: add short option for --detachNguyễn Thái Ngọc Duy, Jan 30, 2019
  32. 15/19 switch: no implicit dwim, use --guess to dwimNguyễn Thái Ngọc Duy, Jan 30, 2019
  33. 16/19 switch: no worktree status unless real branch switch happensNguyễn Thái Ngọc Duy, Jan 30, 2019
  34. 17/19 t: add tests for switchNguyễn Thái Ngọc Duy, Jan 30, 2019
  35. Eric SunshineJan 31, 2019
  36. 18/19 completion: support switchNguyễn Thái Ngọc Duy, Jan 30, 2019
  37. 19/19 doc: promote "git switch"Nguyễn Thái Ngọc Duy, Jan 30, 2019
  38. Eric SunshineJan 31, 2019
  39. Duy NguyenJan 31, 2019
  40. SZEDER GáborJan 31, 2019
  41. Duy NguyenJan 31, 2019
  42. Junio C HamanoJan 31, 2019
  43. Duy NguyenFeb 2, 2019
  44. Junio C HamanoJan 31, 2019
  45. 00/19 Add new command "switch"Nguyễn Thái Ngọc Duy, Feb 8, 2019
  46. 01/19 git-checkout.txt: fix one syntax lineNguyễn Thái Ngọc Duy, Feb 8, 2019
  47. 02/19 doc: document --overwrite-ignoreNguyễn Thái Ngọc Duy, Feb 8, 2019
  48. 03/19 t: rename t2014-switch.sh to t2014-checkout-switch.shNguyễn Thái Ngọc Duy, Feb 8, 2019
  49. 04/19 checkout: factor out some code in parse_branchname_arg()Nguyễn Thái Ngọc Duy, Feb 8, 2019
  50. 05/19 checkout: make "opts" in cmd_checkout() a pointerNguyễn Thái Ngọc Duy, Feb 8, 2019
  51. 06/19 checkout: move 'confict_style' and 'dwim_..' to checkout_optsNguyễn Thái Ngọc Duy, Feb 8, 2019
  52. Junio C HamanoFeb 15, 2019
  53. 07/19 checkout: split options[] array in three piecesNguyễn Thái Ngọc Duy, Feb 8, 2019
  54. 08/19 checkout: split part of it to new command switchNguyễn Thái Ngọc Duy, Feb 8, 2019
  55. 09/19 switch: better names for -b and -BNguyễn Thái Ngọc Duy, Feb 8, 2019
  56. Eric SunshineFeb 11, 2019
  57. 10/19 switch: remove -lNguyễn Thái Ngọc Duy, Feb 8, 2019
  58. 11/19 switch: stop accepting pathspecNguyễn Thái Ngọc Duy, Feb 8, 2019
  59. 12/19 switch: reject "do nothing" caseNguyễn Thái Ngọc Duy, Feb 8, 2019
  60. 13/19 switch: only allow explicit detached HEADNguyễn Thái Ngọc Duy, Feb 8, 2019
  61. 14/19 switch: add short option for --detachNguyễn Thái Ngọc Duy, Feb 8, 2019
  62. 15/19 switch: no implicit dwim, use --guess to dwimNguyễn Thái Ngọc Duy, Feb 8, 2019
  63. Eric SunshineFeb 10, 2019
  64. 16/19 switch: no worktree status unless real branch switch happensNguyễn Thái Ngọc Duy, Feb 8, 2019
  65. 17/19 t: add tests for switchNguyễn Thái Ngọc Duy, Feb 8, 2019
  66. 18/19 completion: support switchNguyễn Thái Ngọc Duy, Feb 8, 2019
  67. SZEDER GáborFeb 8, 2019
  68. Duy NguyenFeb 9, 2019
  69. 19/19 doc: promote "git switch"Nguyễn Thái Ngọc Duy, Feb 8, 2019
  70. 00/21 Add new command "switch"Nguyễn Thái Ngọc Duy, Mar 8, 2019
  71. 01/21 git-checkout.txt: spell out --no-optionNguyễn Thái Ngọc Duy, Mar 8, 2019
  72. Eric SunshineMar 10, 2019
  73. 02/21 git-checkout.txt: fix one syntax lineNguyễn Thái Ngọc Duy, Mar 8, 2019
  74. 03/21 doc: document --overwrite-ignoreNguyễn Thái Ngọc Duy, Mar 8, 2019
  75. 04/21 git-checkout.txt: fix monospace typesetNguyễn Thái Ngọc Duy, Mar 8, 2019
  76. Martin ÅgrenMar 9, 2019
  77. Duy NguyenMar 11, 2019
  78. Martin ÅgrenMar 11, 2019
  79. 05/21 t: rename t2014-switch.sh to t2014-checkout-switch.shNguyễn Thái Ngọc Duy, Mar 8, 2019
  80. 06/21 checkout: factor out some code in parse_branchname_arg()Nguyễn Thái Ngọc Duy, Mar 8, 2019
  81. 07/21 checkout: make "opts" in cmd_checkout() a pointerNguyễn Thái Ngọc Duy, Mar 8, 2019
  82. 08/21 checkout: move 'confict_style' and 'dwim_..' to checkout_optsNguyễn Thái Ngọc Duy, Mar 8, 2019
  83. 09/21 checkout: split options[] array in three piecesNguyễn Thái Ngọc Duy, Mar 8, 2019
  84. 10/21 checkout: split part of it to new command 'switch'Nguyễn Thái Ngọc Duy, Mar 8, 2019
  85. Martin ÅgrenMar 9, 2019
  86. Jacob KellerMar 10, 2019
  87. Elijah NewrenMar 11, 2019
  88. Phillip WoodMar 11, 2019
  89. Duy NguyenMar 11, 2019
  90. Phillip WoodMar 11, 2019
  91. Duy NguyenMar 12, 2019
  92. Elijah NewrenMar 11, 2019
  93. Phillip WoodMar 11, 2019
  94. Elijah NewrenMar 11, 2019
  95. Phillip WoodMar 12, 2019
  96. Duy NguyenMar 12, 2019
  97. Eric SunshineMar 12, 2019
  98. Elijah NewrenMar 12, 2019
  99. Eric SunshineMar 12, 2019
  100. Junio C HamanoMar 13, 2019
  101. Duy NguyenMar 14, 2019
  102. Phillip WoodMar 14, 2019
  103. Duy NguyenMar 14, 2019
  104. Elijah NewrenMar 14, 2019
  105. Junio C HamanoMar 18, 2019
  106. Duy NguyenMar 18, 2019
  107. Elijah NewrenMar 18, 2019
  108. Duy NguyenMar 20, 2019
  109. Jacob KellerMar 15, 2019
  110. Duy NguyenMar 12, 2019
  111. Elijah NewrenMar 12, 2019
  112. Phillip WoodMar 14, 2019
  113. Duy NguyenMar 14, 2019
  114. Elijah NewrenMar 14, 2019
  115. Junio C HamanoMar 14, 2019
  116. Elijah NewrenMar 14, 2019
  117. Junio C HamanoMar 14, 2019
  118. Duy NguyenMar 14, 2019
  119. unpack-trees: fix oneway_merge accidentally carry over stage indexNguyễn Thái Ngọc Duy, Mar 17, 2019
  120. Junio C HamanoMar 18, 2019
  121. Duy NguyenMar 18, 2019
  122. Junio C HamanoMar 18, 2019
  123. unpack-trees: fix oneway_merge accidentally carry over stage indexNguyễn Thái Ngọc Duy, Mar 18, 2019
  124. Elijah NewrenMar 18, 2019
  125. Phillip WoodMar 19, 2019
  126. Junio C HamanoMar 20, 2019
  127. Duy NguyenMar 20, 2019
  128. Duy NguyenMar 26, 2019
  129. Elijah NewrenMar 26, 2019
  130. Duy NguyenMar 26, 2019
  131. Elijah NewrenMar 26, 2019
  132. Duy NguyenMar 26, 2019
  133. Phillip WoodMar 27, 2019
  134. Duy NguyenMar 28, 2019
  135. Elijah NewrenMar 28, 2019
  136. Phillip WoodMar 28, 2019
  137. Elijah NewrenMar 28, 2019
  138. Phillip WoodMar 29, 2019
  139. Duy NguyenMar 29, 2019
  140. Elijah NewrenMar 29, 2019
  141. Phillip WoodApr 25, 2019
  142. Junio C HamanoApr 1, 2019
  143. Elijah NewrenMar 11, 2019
  144. Phillip WoodMar 12, 2019
  145. Elijah NewrenMar 12, 2019
  146. Phillip WoodMar 14, 2019
  147. checkout.txt: note about losing staged changes with --mergeNguyễn Thái Ngọc Duy, Mar 19, 2019
  148. Phillip WoodMar 19, 2019
  149. Junio C HamanoMar 20, 2019
  150. Duy NguyenMar 20, 2019
  151. Junio C HamanoMar 20, 2019
  152. Duy NguyenMar 20, 2019
  153. Junio C HamanoMar 20, 2019
  154. Elijah NewrenMar 20, 2019
  155. Duy NguyenMar 20, 2019
  156. Elijah NewrenMar 21, 2019
  157. Junio C HamanoMar 21, 2019
  158. Duy NguyenMar 13, 2019
  159. Elijah NewrenMar 13, 2019
  160. 11/21 switch: better names for -b and -BNguyễn Thái Ngọc Duy, Mar 8, 2019
  161. 12/21 switch: remove -lNguyễn Thái Ngọc Duy, Mar 8, 2019
  162. 13/21 switch: stop accepting pathspecNguyễn Thái Ngọc Duy, Mar 8, 2019
  163. 14/21 switch: reject "do nothing" caseNguyễn Thái Ngọc Duy, Mar 8, 2019
  164. 15/21 switch: only allow explicit detached HEADNguyễn Thái Ngọc Duy, Mar 8, 2019
  165. 16/21 switch: add short option for --detachNguyễn Thái Ngọc Duy, Mar 8, 2019
  166. 17/21 switch: no implicit dwim, use --guess to dwimNguyễn Thái Ngọc Duy, Mar 8, 2019
  167. Eckhard MaaßMar 13, 2019
  168. Eric SunshineMar 15, 2019
  169. Duy NguyenMar 15, 2019
  170. Junio C HamanoMar 18, 2019
  171. Duy NguyenMar 16, 2019
  172. 18/21 switch: no worktree status unless real branch switch happensNguyễn Thái Ngọc Duy, Mar 8, 2019
  173. Eric SunshineMar 10, 2019
  174. 19/21 t: add tests for switchNguyễn Thái Ngọc Duy, Mar 8, 2019
  175. Eric SunshineMar 10, 2019
  176. Andrei RybakMar 10, 2019
  177. 20/21 completion: support switchNguyễn Thái Ngọc Duy, Mar 8, 2019
  178. 21/21 doc: promote "git switch"Nguyễn Thái Ngọc Duy, Mar 8, 2019
  179. Ramsay JonesMar 8, 2019
  180. Duy NguyenMar 9, 2019
  181. 00/26 Add new command 'switch'Nguyễn Thái Ngọc Duy, Mar 17, 2019
  182. 01/26 git-checkout.txt: spell out --no-optionNguyễn Thái Ngọc Duy, Mar 17, 2019
  183. 02/26 git-checkout.txt: fix one syntax lineNguyễn Thái Ngọc Duy, Mar 17, 2019
  184. 03/26 doc: document --overwrite-ignoreNguyễn Thái Ngọc Duy, Mar 17, 2019
  185. Martin ÅgrenMar 17, 2019
  186. 04/26 git-checkout.txt: fix monospace typesetNguyễn Thái Ngọc Duy, Mar 17, 2019
  187. Martin ÅgrenMar 17, 2019
  188. 05/26 t: rename t2014-switch.sh to t2014-checkout-switch.shNguyễn Thái Ngọc Duy, Mar 17, 2019
  189. 06/26 checkout: advice how to get out of detached HEAD modeNguyễn Thái Ngọc Duy, Mar 17, 2019
  190. 07/26 checkout: keep most #include sortedNguyễn Thái Ngọc Duy, Mar 17, 2019
  191. 08/26 checkout: factor out some code in parse_branchname_arg()Nguyễn Thái Ngọc Duy, Mar 17, 2019
  192. 09/26 checkout: make "opts" in cmd_checkout() a pointerNguyễn Thái Ngọc Duy, Mar 17, 2019
  193. 10/26 checkout: move 'confict_style' and 'dwim_..' to checkout_optsNguyễn Thái Ngọc Duy, Mar 17, 2019
  194. 11/26 checkout: split options[] array in three piecesNguyễn Thái Ngọc Duy, Mar 17, 2019
  195. 12/26 checkout: split part of it to new command 'switch'Nguyễn Thái Ngọc Duy, Mar 17, 2019
  196. Elijah NewrenMar 18, 2019
  197. 13/26 switch: better names for -b and -BNguyễn Thái Ngọc Duy, Mar 17, 2019
  198. 14/26 switch: add --discard-changesNguyễn Thái Ngọc Duy, Mar 17, 2019
  199. Eric SunshineMar 18, 2019
  200. 15/26 switch: remove -lNguyễn Thái Ngọc Duy, Mar 17, 2019
  201. 16/26 switch: stop accepting pathspecNguyễn Thái Ngọc Duy, Mar 17, 2019
  202. 17/26 switch: reject "do nothing" caseNguyễn Thái Ngọc Duy, Mar 17, 2019
  203. 18/26 switch: only allow explicit detached HEADNguyễn Thái Ngọc Duy, Mar 17, 2019
  204. 19/26 switch: add short option for --detachNguyễn Thái Ngọc Duy, Mar 17, 2019
  205. 20/26 switch: implicit dwim, use --no-guess to disable itNguyễn Thái Ngọc Duy, Mar 17, 2019
  206. 21/26 switch: no worktree status unless real branch switch happensNguyễn Thái Ngọc Duy, Mar 17, 2019
  207. 22/26 switch: reject if some operation is in progressNguyễn Thái Ngọc Duy, Mar 17, 2019
  208. Phillip WoodMar 20, 2019
  209. 23/26 switch: --orphan defaults to empty tree as HEADNguyễn Thái Ngọc Duy, Mar 17, 2019
  210. 24/26 t: add tests for switchNguyễn Thái Ngọc Duy, Mar 17, 2019
  211. 25/26 completion: support switchNguyễn Thái Ngọc Duy, Mar 17, 2019
  212. 26/26 doc: promote "git switch"Nguyễn Thái Ngọc Duy, Mar 17, 2019
  213. Duy NguyenMar 17, 2019
  214. Junio C HamanoMar 18, 2019
  215. Duy NguyenMar 18, 2019
  216. Junio C HamanoMar 19, 2019
  217. 00/26 Add new command 'switch'Nguyễn Thái Ngọc Duy, Mar 21, 2019
  218. 01/26 git-checkout.txt: spell out --no-optionNguyễn Thái Ngọc Duy, Mar 21, 2019
  219. 02/26 git-checkout.txt: fix one syntax lineNguyễn Thái Ngọc Duy, Mar 21, 2019
  220. 03/26 doc: document --overwrite-ignoreNguyễn Thái Ngọc Duy, Mar 21, 2019
  221. 04/26 git-checkout.txt: fix monospace typesetNguyễn Thái Ngọc Duy, Mar 21, 2019
  222. 05/26 t: rename t2014-switch.sh to t2014-checkout-switch.shNguyễn Thái Ngọc Duy, Mar 21, 2019
  223. 06/26 checkout: advice how to get out of detached HEAD modeNguyễn Thái Ngọc Duy, Mar 21, 2019
  224. 07/26 checkout: keep most #include sortedNguyễn Thái Ngọc Duy, Mar 21, 2019
  225. 08/26 checkout: factor out some code in parse_branchname_arg()Nguyễn Thái Ngọc Duy, Mar 21, 2019
  226. 09/26 checkout: make "opts" in cmd_checkout() a pointerNguyễn Thái Ngọc Duy, Mar 21, 2019
  227. 10/26 checkout: move 'confict_style' and 'dwim_..' to checkout_optsNguyễn Thái Ngọc Duy, Mar 21, 2019
  228. 12/26 checkout: split part of it to new command 'switch'Nguyễn Thái Ngọc Duy, Mar 21, 2019
  229. 13/26 switch: better names for -b and -BNguyễn Thái Ngọc Duy, Mar 21, 2019
  230. 14/26 switch: add --discard-changesNguyễn Thái Ngọc Duy, Mar 21, 2019
  231. 15/26 switch: remove -lNguyễn Thái Ngọc Duy, Mar 21, 2019
  232. 16/26 switch: stop accepting pathspecNguyễn Thái Ngọc Duy, Mar 21, 2019
  233. 11/26 checkout: split options[] array in three piecesNguyễn Thái Ngọc Duy, Mar 21, 2019
  234. 17/26 switch: reject "do nothing" caseNguyễn Thái Ngọc Duy, Mar 21, 2019
  235. 18/26 switch: only allow explicit detached HEADNguyễn Thái Ngọc Duy, Mar 21, 2019
  236. 19/26 switch: add short option for --detachNguyễn Thái Ngọc Duy, Mar 21, 2019
  237. 20/26 switch: implicit dwim, use --no-guess to disable itNguyễn Thái Ngọc Duy, Mar 21, 2019
  238. 21/26 switch: no worktree status unless real branch switch happensNguyễn Thái Ngọc Duy, Mar 21, 2019
  239. 22/26 switch: reject if some operation is in progressNguyễn Thái Ngọc Duy, Mar 21, 2019
  240. 23/26 switch: make --orphan switch to an empty treeNguyễn Thái Ngọc Duy, Mar 21, 2019
  241. 24/26 t: add tests for switchNguyễn Thái Ngọc Duy, Mar 21, 2019
  242. 25/26 completion: support switchNguyễn Thái Ngọc Duy, Mar 21, 2019
  243. 26/26 doc: promote "git switch"Nguyễn Thái Ngọc Duy, Mar 21, 2019
  244. Andrei RybakMar 22, 2019
  245. Duy NguyenMar 22, 2019
  246. Elijah NewrenMar 21, 2019
  247. Junio C HamanoMar 22, 2019
  248. Duy NguyenMar 22, 2019
  249. 00/27 Add new command 'switch'Nguyễn Thái Ngọc Duy, Mar 29, 2019
  250. 01/27 git-checkout.txt: spell out --no-optionNguyễn Thái Ngọc Duy, Mar 29, 2019
  251. 02/27 git-checkout.txt: fix one syntax lineNguyễn Thái Ngọc Duy, Mar 29, 2019
  252. 03/27 doc: document --overwrite-ignoreNguyễn Thái Ngọc Duy, Mar 29, 2019
  253. 04/27 git-checkout.txt: fix monospace typesetNguyễn Thái Ngọc Duy, Mar 29, 2019
  254. 05/27 t: rename t2014-switch.sh to t2014-checkout-switch.shNguyễn Thái Ngọc Duy, Mar 29, 2019
  255. 06/27 checkout: advice how to get out of detached HEAD modeNguyễn Thái Ngọc Duy, Mar 29, 2019
  256. 07/27 checkout: inform the user when removing branch stateNguyễn Thái Ngọc Duy, Mar 29, 2019
  257. SZEDER GáborJul 2, 2019
  258. Duy NguyenJul 2, 2019
  259. SZEDER GáborJul 2, 2019
  260. Junio C HamanoJul 2, 2019
  261. Duy NguyenJul 4, 2019
  262. 08/27 checkout: keep most #include sortedNguyễn Thái Ngọc Duy, Mar 29, 2019
  263. 09/27 checkout: factor out some code in parse_branchname_arg()Nguyễn Thái Ngọc Duy, Mar 29, 2019
  264. 10/27 checkout: make "opts" in cmd_checkout() a pointerNguyễn Thái Ngọc Duy, Mar 29, 2019
  265. 11/27 checkout: move 'confict_style' and 'dwim_..' to checkout_optsNguyễn Thái Ngọc Duy, Mar 29, 2019
  266. 12/27 checkout: split options[] array in three piecesNguyễn Thái Ngọc Duy, Mar 29, 2019
  267. 13/27 checkout: split part of it to new command 'switch'Nguyễn Thái Ngọc Duy, Mar 29, 2019
  268. 14/27 switch: better names for -b and -BNguyễn Thái Ngọc Duy, Mar 29, 2019
  269. 15/27 switch: add --discard-changesNguyễn Thái Ngọc Duy, Mar 29, 2019
  270. Phillip WoodApr 25, 2019
  271. Duy NguyenApr 25, 2019
  272. Phillip WoodApr 29, 2019
  273. 16/27 switch: remove -lNguyễn Thái Ngọc Duy, Mar 29, 2019
  274. 17/27 switch: stop accepting pathspecNguyễn Thái Ngọc Duy, Mar 29, 2019
  275. 18/27 switch: reject "do nothing" caseNguyễn Thái Ngọc Duy, Mar 29, 2019
  276. 19/27 switch: only allow explicit detached HEADNguyễn Thái Ngọc Duy, Mar 29, 2019
  277. 20/27 switch: add short option for --detachNguyễn Thái Ngọc Duy, Mar 29, 2019
  278. 21/27 switch: implicit dwim, use --no-guess to disable itNguyễn Thái Ngọc Duy, Mar 29, 2019
  279. 22/27 switch: no worktree status unless real branch switch happensNguyễn Thái Ngọc Duy, Mar 29, 2019
  280. 23/27 switch: reject if some operation is in progressNguyễn Thái Ngọc Duy, Mar 29, 2019
  281. Elijah NewrenMar 29, 2019
  282. Phillip WoodApr 25, 2019
  283. Duy NguyenApr 29, 2019
  284. Phillip WoodApr 29, 2019
  285. 24/27 switch: make --orphan switch to an empty treeNguyễn Thái Ngọc Duy, Mar 29, 2019
  286. 25/27 t: add tests for switchNguyễn Thái Ngọc Duy, Mar 29, 2019
  287. 26/27 completion: support switchNguyễn Thái Ngọc Duy, Mar 29, 2019
  288. 27/27 doc: promote "git switch"Nguyễn Thái Ngọc Duy, Mar 29, 2019
  289. Elijah NewrenMar 29, 2019

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.