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

[PATCH 08/19] checkout: split part of it to new command switch

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Jan 30, 2019, 09:48 UTC
Message-ID
<20190130094831.10420-9-pclouds@gmail.com>
In-Reply-To
<20190130094831.10420-1-pclouds@gmail.com>

"git checkout" doing too many things is a source of confusion for many users (and it even bites old timers sometimes). To remedy that, the command will be split into two new ones: switch and something-to-checkout-paths. The good old "git checkout" command is still here and will be until all (or most of users) are sick of it.

See the new man page for the final design of switch. The actual implementation though is still pretty much the same as "git checkout" and not completely aligned with the man page. Following patches will adjust their behavior to match the man page.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 .gitignore                        |   1 +
 Documentation/config/advice.txt   |  13 +-
 Documentation/config/branch.txt   |   4 +-
 Documentation/config/checkout.txt |   9 +-
 Documentation/config/diff.txt     |   3 +-
 Documentation/git-checkout.txt    |   4 +
 Documentation/git-switch.txt      | 236 ++++++++++++++++++++++++++++++
 Documentation/gitattributes.txt   |   3 +-
 Documentation/githooks.txt        |   8 +-
 Makefile                          |   1 +
 builtin.h                         |   1 +
 builtin/checkout.c                |  60 ++++++--
 command-list.txt                  |   1 +
 git.c                             |   1 +
 14 files changed, 318 insertions(+), 27 deletions(-)
 create mode 100644 Documentation/git-switch.txt
diff --git a/.gitignore b/.gitignore
index 0d77ea5894..8e2b89047f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -167,6 +167,7 @@
 /git-submodule
 /git-submodule--helper
 /git-svn
+/git-switch
 /git-symbolic-ref
 /git-tag
 /git-unpack-file
diff --git a/Documentation/config/advice.txt b/Documentation/config/advice.txt
index 88620429ea..239d479506 100644
--- a/Documentation/config/advice.txt
+++ b/Documentation/config/advice.txt
@@ -42,7 +42,8 @@ advice.*::
 		state in the output of linkgit:git-status[1], in
 		the template shown when writing commit messages in
 		linkgit:git-commit[1], and in the help message shown
-		by linkgit:git-checkout[1] when switching branch.
+		by linkgit:git-switch[1] or
+		linkgit:git-checkout[1] when switching branch.
 	statusUoption::
 		Advise to consider using the `-u` option to linkgit:git-status[1]
 		when the command takes more than 2 seconds to enumerate untracked
@@ -62,12 +63,14 @@ advice.*::
 		your information is guessed from the system username and
 		domain name.
 	detachedHead::
-		Advice shown when you used linkgit:git-checkout[1] to
-		move to the detach HEAD state, to instruct how to create
-		a local branch after the fact.
+		Advice shown when you used
+		linkgit:git-switch[1] or linkgit:git-checkout[1]
+		to move to the detach HEAD state, to instruct how to
+		create a local branch after the fact.
 	checkoutAmbiguousRemoteBranchName::
 		Advice shown when the argument to
-		linkgit:git-checkout[1] ambiguously resolves to a
+		linkgit:git-checkout[1] and linkgit:git-switch[1]
+		ambiguously resolves to a
 		remote tracking branch on more than one remote in
 		situations where an unambiguous argument would have
 		otherwise caused a remote-tracking branch to be
diff --git a/Documentation/config/branch.txt b/Documentation/config/branch.txt
index 019d60ede2..8050466159 100644
--- a/Documentation/config/branch.txt
+++ b/Documentation/config/branch.txt
@@ -1,5 +1,5 @@
 branch.autoSetupMerge::
-	Tells 'git branch' and 'git checkout' to set up new branches
+	Tells 'git branch', 'git switch' and 'git checkout' to set up new branches
 	so that linkgit:git-pull[1] will appropriately merge from the
 	starting point branch. Note that even if this option is not set,
 	this behavior can be chosen per-branch using the `--track`
@@ -11,7 +11,7 @@ branch.autoSetupMerge::
 	branch. This option defaults to true.
 
 branch.autoSetupRebase::
-	When a new branch is created with 'git branch' or 'git checkout'
+	When a new branch is created with 'git branch', 'git switch' or 'git checkout'
 	that tracks another branch, this variable tells Git to set
 	up pull to rebase instead of merge (see "branch.<name>.rebase").
 	When `never`, rebase is never automatically set to true.
diff --git a/Documentation/config/checkout.txt b/Documentation/config/checkout.txt
index 73380a8d86..fc211eca58 100644
--- a/Documentation/config/checkout.txt
+++ b/Documentation/config/checkout.txt
@@ -1,5 +1,6 @@
 checkout.defaultRemote::
-	When you run 'git checkout <something>' and only have one
+	When you run 'git checkout <something>'
+	or 'git switch <something>' and only have one
 	remote, it may implicitly fall back on checking out and
 	tracking e.g. 'origin/<something>'. This stops working as soon
 	as you have more than one remote with a '<something>'
@@ -8,8 +9,10 @@ checkout.defaultRemote::
 	disambiguation. The typical use-case is to set this to
 	`origin`.
 +
-Currently this is used by linkgit:git-checkout[1] when 'git checkout
-<something>' will checkout the '<something>' branch on another remote,
+Currently this is used by linkgit:git-switch[1] and
+linkgit:git-checkout[1] when 'git checkout <something>'
+or 'git switch <something>'
+will checkout the '<something>' branch on another remote,
 and by linkgit:git-worktree[1] when 'git worktree add' refers to a
 remote branch. This setting might be used for other checkout-like
 commands or functionality in the future.
diff --git a/Documentation/config/diff.txt b/Documentation/config/diff.txt
index e48bb987d7..b3b304ee12 100644
--- a/Documentation/config/diff.txt
+++ b/Documentation/config/diff.txt
@@ -78,7 +78,8 @@ diff.external::
 diff.ignoreSubmodules::
 	Sets the default value of --ignore-submodules. Note that this
 	affects only 'git diff' Porcelain, and not lower level 'diff'
-	commands such as 'git diff-files'. 'git checkout' also honors
+	commands such as 'git diff-files'. 'git checkout'
+	and 'git switch' also honor
 	this setting when reporting uncommitted changes. Setting it to
 	'all' disables the submodule summary normally shown by 'git commit'
 	and 'git status' when `status.submoduleSummary` is set unless it is
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index 9ac01f7967..31c6cbef19 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -556,6 +556,10 @@ $ edit frotz
 $ git add frotz
 ------------
 
+SEE ALSO
+--------
+linkgit:git-switch[1]
+
 GIT
 ---
 Part of the linkgit:git[1] suite
diff --git a/Documentation/git-switch.txt b/Documentation/git-switch.txt
new file mode 100644
index 0000000000..953c9747b2
--- /dev/null
+++ b/Documentation/git-switch.txt
@@ -0,0 +1,236 @@
+git-switch(1)
+=============
+
+NAME
+----
+git-switch - Switch branches
+
+SYNOPSIS
+--------
+[verse]
+'git switch' [<options>] [--guess] <branch>
+'git switch' [<options>] --detach [<start_point>>]
+'git switch' [<options>] [[-c|-C|--orphan] <new_branch>] [<start_point>]
+
+DESCRIPTION
+-----------
+Switch to a specified branch and update files in the working tree to
+match it. Optionally a new branch could be created with either `-c` or
+`-C`, or detach from any branch with `--detach`, along with switching.
+
+OPTIONS
+-------
+<branch>::
+	Branch to switch to.
+
+<new_branch>::
+	Name for the new branch.
+
+<start_point>::
+	The name of a commit at which to switch to before creating a
+	new branch or detach from.
++
+You can use the `"@{-N}"` syntax to refer to the N-th last
+branch/commit switched to "git switch" or "git checkout"
+operation. You may also specify `-` which is synonymous to `"@{-1}`.
++
+As a special case, you may use `"A...B"` as a shortcut for the merge
+base of `A` and `B` if there is exactly one merge base. You can leave
+out at most one of `A` and `B`, in which case it defaults to `HEAD`.
+
+-c <new_branch>::
+--create <new_branch>::
+	Create a new branch named <new_branch> and start it at
+	<start_point>; see linkgit:git-branch[1] for details.
+
+-C <new_branch>::
+--force-create <new_branch>::
+	Creates the branch <new_branch> and start it at <start_point>;
+	if it already exists, then reset it to <start_point>. This is
+	equivalent to running "git branch" with "-f"; see
+	linkgit:git-branch[1] for details.
+
+-d::
+--detach::
+	Switch to a commit for inspection and discardable
+	experiments. See the "DETACHED HEAD" section in
+	linkgit:git-checkout[1] for details.
+
+-g::
+--guess::
+	If <branch> is not found but there does exist a tracking
+	branch in exactly one remote (call it <remote>) with a
+	matching name, treat as equivalent to
++
+------------
+$ git switch -c <branch> --track <remote>/<branch>
+------------
++
+If the branch exists in multiple remotes and one of them is named by
+the `checkout.defaultRemote` configuration variable, we'll use that
+one for the purposes of disambiguation, even if the `<branch>` isn't
+unique across all remotes. Set it to e.g. `checkout.defaultRemote=origin`
+to always checkout remote branches from there if `<branch>` is
+ambiguous but exists on the 'origin' remote. See also
+`checkout.defaultRemote` in linkgit:git-config[1].
+
+-q::
+--quiet::
+	Quiet, suppress feedback messages.
+
+-f::
+--force::
+	Proceed even if the index or the working tree differs from
+	HEAD.  This is used to throw away local changes.
+
+--[no-]progress::
+	Progress status is reported on the standard error stream
+	by default when it is attached to a terminal, unless `--quiet`
+	is specified. This flag enables progress reporting even if not
+	attached to a terminal, regardless of `--quiet`.
+
+-t::
+--track::
+	When creating a new branch, set up "upstream" configuration.
+	`-c` is implied. See "--track" in linkgit:git-branch[1] for
+	details.
++
+If no `-c` option is given, the name of the new branch will be derived
+from the remote-tracking branch, by looking at the local part of the
+refspec configured for the corresponding remote, and then stripping
+the initial part up to the "*".  This would tell us to use "hack" as
+the local branch when branching off of "origin/hack" (or
+"remotes/origin/hack", or even "refs/remotes/origin/hack").  If the
+given name has no slash, or the above guessing results in an empty
+name, the guessing is aborted.  You can explicitly give a name with
+`-c` in such a case.
+
+--no-track::
+	Do not set up "upstream" configuration, even if the
+	branch.autoSetupMerge configuration variable is true.
+
+-m::
+--merge::
+	If you have local modifications to one or more files that are
+	different between the current branch and the branch to which
+	you are switching, the command refuses to switch branches in
+	order to preserve your modifications in context.  However,
+	with this option, a three-way merge between the current
+	branch, your working tree contents, and the new branch is
+	done, and you will be on the new branch.
++
+When a merge conflict happens, the index entries for conflicting
+paths are left unmerged, and you need to resolve the conflicts
+and mark the resolved paths with `git add` (or `git rm` if the merge
+should result in deletion of the path).
+
+--conflict=<style>::
+	The same as --merge option above, but changes the way the
+	conflicting hunks are presented, overriding the
+	merge.conflictStyle configuration variable.  Possible values are
+	"merge" (default) and "diff3" (in addition to what is shown by
+	"merge" style, shows the original contents).
+
+--orphan <new_branch>::
+	Create a new 'orphan' branch, named <new_branch>, started from
+	<start_point> and switch to it. See explanation of the same
+	option in linkgit:git-checkout[1] for details.
+
+--ignore-other-worktrees::
+	`git switch` refuses when the wanted ref is already
+	checked out by another worktree. This option makes it check
+	the ref out anyway. In other words, the ref can be held by
+	more than one worktree.
+
+--[no-]recurse-submodules::
+	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)
+	is used, the work trees of submodules will not be updated.
+	Just like linkgit:git-submodule[1], this will detach the
+	submodules HEAD.
+
+EXAMPLES
+--------
+
+The following command switches to the "master" branch:
+
+------------
+$ git switch master
+------------
+
+After working in the wrong branch, switching to the correct branch
+would be done using:
+
+------------
+$ git switch mytopic
+------------
+
+However, your "wrong" branch and correct "mytopic" branch may differ
+in files that you have modified locally, in which case the above
+switch would fail like this:
+
+------------
+$ git switch mytopic
+error: You have local changes to 'frotz'; not switching branches.
+------------
+
+You can give the `-m` flag to the command, which would try a three-way
+merge:
+
+------------
+$ git switch -m mytopic
+Auto-merging frotz
+------------
+
+After this three-way merge, the local modifications are _not_
+registered in your index file, so `git diff` would show you what
+changes you made since the tip of the new branch.
+
+To switch back to the previous branch before we switched to mytopic
+(i.e. "master" branch):
+
+------------
+$ git switch -
+------------
+
+You can grow a new branch from any commit. For example, switch to
+"HEAD~3" and create branch "fixup":
+
+------------
+$ git switch -c fixup HEAD~3
+Switched to a new branch 'fixup'
+------------
+
+If you want to start a new branch from a remote branch of the same
+name, use `-g`:
+
+------------
+$ git switch -g new-topic
+Branch 'new-topic' set up to track remote branch 'new-topic' from 'origin'
+Switched to a new branch 'new-topic'
+------------
+
+To check out commit "HEAD~3" for temporary inspection or experiment
+without creating a new branch:
+
+------------
+$ git switch --detach HEAD~3
+HEAD is now at 9fc9555312 Merge branch 'cc/shared-index-permbits'
+------------
+
+If it turns out whatever you have done is worth keeping, you can
+always create a new name for it (without switching away):
+
+------------
+$ git switch -c good-surprises
+------------
+
+SEE ALSO
+--------
+linkgit:git-checkout[1]
+
+GIT
+---
+Part of the linkgit:git[1] suite
diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt
index b8392fc330..5731caa4c6 100644
--- a/Documentation/gitattributes.txt
+++ b/Documentation/gitattributes.txt
@@ -112,7 +112,8 @@ Checking-out and checking-in
 
 These attributes affect how the contents stored in the
 repository are copied to the working tree files when commands
-such as 'git checkout' and 'git merge' run.  They also affect how
+such as 'git switch', 'git checkout'  and 'git merge' run.
+They also affect how
 Git stores the contents you prepare in the working tree in the
 repository upon 'git add' and 'git commit'.
 
diff --git a/Documentation/githooks.txt b/Documentation/githooks.txt
index 959044347e..e257a7810a 100644
--- a/Documentation/githooks.txt
+++ b/Documentation/githooks.txt
@@ -161,12 +161,13 @@ rebased, and is not set when rebasing the current branch.
 post-checkout
 ~~~~~~~~~~~~~
 
-This hook is invoked when a linkgit:git-checkout[1] is run after having updated the
+This hook is invoked when a linkgit:git-checkout[1] or
+linkgit:git-switch[1] is run after having updated the
 worktree.  The hook is given three parameters: the ref of the previous HEAD,
 the ref of the new HEAD (which may or may not have changed), and a flag
 indicating whether the checkout was a branch checkout (changing branches,
 flag=1) or a file checkout (retrieving a file from the index, flag=0).
-This hook cannot affect the outcome of `git checkout`.
+This hook cannot affect the outcome of `git switch` or `git checkout`.
 
 It is also run after linkgit:git-clone[1], unless the `--no-checkout` (`-n`) option is
 used. The first parameter given to the hook is the null-ref, the second the
@@ -402,7 +403,8 @@ exit with a zero status.
 For example, the hook can simply run `git read-tree -u -m HEAD "$1"`
 in order to emulate `git fetch` that is run in the reverse direction
 with `git push`, as the two-tree form of `git read-tree -u -m` is
-essentially the same as `git checkout` that switches branches while
+essentially the same as `git switch` or `git checkout`
+that switches branches while
 keeping the local changes in the working tree that do not interfere
 with the difference between the branches.
 
diff --git a/Makefile b/Makefile
index 6e8d017e8e..0e5b29390c 100644
--- a/Makefile
+++ b/Makefile
@@ -789,6 +789,7 @@ BUILT_INS += git-merge-subtree$X
 BUILT_INS += git-show$X
 BUILT_INS += git-stage$X
 BUILT_INS += git-status$X
+BUILT_INS += git-switch$X
 BUILT_INS += git-whatchanged$X
 
 # what 'all' will build and 'install' will install in gitexecdir,
diff --git a/builtin.h b/builtin.h
index 6538932e99..c64e44450e 100644
--- a/builtin.h
+++ b/builtin.h
@@ -227,6 +227,7 @@ extern int cmd_show_index(int argc, const char **argv, const char *prefix);
 extern int cmd_status(int argc, const char **argv, const char *prefix);
 extern int cmd_stripspace(int argc, const char **argv, const char *prefix);
 extern int cmd_submodule__helper(int argc, const char **argv, const char *prefix);
+extern int cmd_switch(int argc, const char **argv, const char *prefix);
 extern int cmd_symbolic_ref(int argc, const char **argv, const char *prefix);
 extern int cmd_tag(int argc, const char **argv, const char *prefix);
 extern int cmd_tar_tree(int argc, const char **argv, const char *prefix);
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 8ea1349cce..2ac53b4302 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -33,6 +33,11 @@ static const char * const checkout_usage[] = {
 	NULL,
 };
 
+static const char * const switch_branch_usage[] = {
+	N_("git switch [<options>] [<branch>]"),
+	NULL,
+};
+
 struct checkout_opts {
 	int patch_mode;
 	int quiet;
@@ -1396,33 +1401,25 @@ static struct option *add_checkout_path_options(struct checkout_opts *opts,
 	return newopts;
 }
 
-int cmd_checkout(int argc, const char **argv, const char *prefix)
+static int checkout_main(int argc, const char **argv, const char *prefix,
+			 struct checkout_opts *opts, struct option *options,
+			 const char * const usagestr[])
 {
-	struct checkout_opts real_opts;
-	struct checkout_opts *opts = &real_opts;
 	struct branch_info new_branch_info;
 	int dwim_remotes_matched = 0;
 	int dwim_new_local_branch;
-	struct option *options = NULL;
 
-	memset(opts, 0, sizeof(*opts));
 	memset(&new_branch_info, 0, sizeof(new_branch_info));
 	opts->overwrite_ignore = 1;
 	opts->prefix = prefix;
 	opts->show_progress = -1;
 	opts->overlay_mode = -1;
-	opts->no_dwim_new_local_branch = 0;
 
 	git_config(git_checkout_config, opts);
 
 	opts->track = BRANCH_TRACK_UNSPECIFIED;
 
-	options = parse_options_dup(options);
-	options = add_common_options(opts, options);
-	options = add_switch_branch_options(opts, options);
-	options = add_checkout_path_options(opts, options);
-
-	argc = parse_options(argc, argv, prefix, options, checkout_usage,
+	argc = parse_options(argc, argv, prefix, options, usagestr,
 			     PARSE_OPT_KEEP_DASHDASH);
 
 	dwim_new_local_branch = !opts->no_dwim_new_local_branch;
@@ -1555,3 +1552,42 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 		return checkout_branch(opts, &new_branch_info);
 	}
 }
+
+int cmd_checkout(int argc, const char **argv, const char *prefix)
+{
+	struct checkout_opts opts;
+	struct option *options = NULL;
+	int ret;
+
+	memset(&opts, 0, sizeof(opts));
+	opts.no_dwim_new_local_branch = 0;
+
+	options = parse_options_dup(options);
+	options = add_common_options(&opts, options);
+	options = add_switch_branch_options(&opts, options);
+	options = add_checkout_path_options(&opts, options);
+
+	ret = checkout_main(argc, argv, prefix, &opts,
+			    options, checkout_usage);
+	FREE_AND_NULL(options);
+	return ret;
+}
+
+int cmd_switch(int argc, const char **argv, const char *prefix)
+{
+	struct checkout_opts opts;
+	struct option *options = NULL;
+	int ret;
+
+	memset(&opts, 0, sizeof(opts));
+	opts.no_dwim_new_local_branch = 0;
+
+	options = parse_options_dup(options);
+	options = add_common_options(&opts, options);
+	options = add_switch_branch_options(&opts, options);
+
+	ret = checkout_main(argc, argv, prefix, &opts,
+			    options, switch_branch_usage);
+	FREE_AND_NULL(options);
+	return ret;
+}
diff --git a/command-list.txt b/command-list.txt
index 3a9af104b5..13317f47d4 100644
--- a/command-list.txt
+++ b/command-list.txt
@@ -171,6 +171,7 @@ git-status                              mainporcelain           info
 git-stripspace                          purehelpers
 git-submodule                           mainporcelain
 git-svn                                 foreignscminterface
+git-switch                              mainporcelain           history
 git-symbolic-ref                        plumbingmanipulators
 git-tag                                 mainporcelain           history
 git-unpack-file                         plumbinginterrogators
diff --git a/git.c b/git.c
index 0ce0e13f0f..31b8e8d6a1 100644
--- a/git.c
+++ b/git.c
@@ -558,6 +558,7 @@ static struct cmd_struct commands[] = {
 	{ "status", cmd_status, RUN_SETUP | NEED_WORK_TREE },
 	{ "stripspace", cmd_stripspace },
 	{ "submodule--helper", cmd_submodule__helper, RUN_SETUP | SUPPORT_SUPER_PREFIX | NO_PARSEOPT },
+	{ "switch", cmd_switch, RUN_SETUP | NEED_WORK_TREE },
 	{ "symbolic-ref", cmd_symbolic_ref, RUN_SETUP },
 	{ "tag", cmd_tag, RUN_SETUP | DELAY_PAGER_CONFIG },
 	{ "unpack-file", cmd_unpack_file, RUN_SETUP | NO_PARSEOPT },
-- 
2.20.1.682.gd5861c6d90
Previous: Nguyễn Thái Ngọc DuyNext: Eric Sunshine
Message 9 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.