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

[PATCH 1/2] builtin: remove merge short flag for switch and restore

From
Justin Tobler <jltobler@gmail.com>
Date
Jul 22, 2025, 18:08 UTC
Message-ID
<20250722180818.1043014-2-jltobler@gmail.com>
In-Reply-To
<20250722180818.1043014-1-jltobler@gmail.com>

Both git-switch(1) and git-restore(1) inherit some common options from git-checkout(1). One such option is the `--merge` flag and its accompanying short flag `-m`.

In previous discussion[1] around removing the experimental marker for git-switch(1), it has been suggested that this short flag could instead be used for an option similar to `--move` from git-branch(1). Such a feature is not yet implemented for this command, but reserving a short flag for an uncommon option is unnecessary and hinders potential future extension.

While these commands are still marked as experimental, remove the `-m` flag from both git-switch(1) and git-restore(1) and update the documentation accordingly. The `--conflict` flag is also now defined explicitly for each command as to remain alongside its related `--merge` companion.

[1]: https://lore.kernel.org/git/877dkdwgfe.fsf@evledraar.gmail.com/
Signed-off-by: Justin Tobler <jltobler@gmail.com>
---
 Documentation/git-restore.adoc |  1 -
 Documentation/git-switch.adoc  |  1 -
 builtin/checkout.c             | 24 ++++++++++++++++--------
 3 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/Documentation/git-restore.adoc b/Documentation/git-restore.adoc
index 877b7772e66..96de9bb5ed7 100644
--- a/Documentation/git-restore.adoc
+++ b/Documentation/git-restore.adoc
@@ -82,7 +82,6 @@ Note that during `git rebase` and `git pull --rebase`, `ours` and
 `theirs` may appear swapped. See the explanation of the same options
 in linkgit:git-checkout[1] for details.
 
-`-m`::
 `--merge`::
 	When restoring files on the working tree from the index,
 	recreate the conflicted merge in the unmerged paths.
diff --git a/Documentation/git-switch.adoc b/Documentation/git-switch.adoc
index 9f62abf9e2b..7b24450f841 100644
--- a/Documentation/git-switch.adoc
+++ b/Documentation/git-switch.adoc
@@ -123,7 +123,6 @@ variable.
 	submodule content is also restored to match the switching
 	target. This is used to throw away local changes.
 
-`-m`::
 `--merge`::
 	If you have local modifications to one or more files that are
 	different between the current branch and the branch to which
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 0a90b86a729..0d5b182166e 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -1689,13 +1689,9 @@ static struct option *add_common_options(struct checkout_opts *opts,
 	struct option options[] = {
 		OPT__QUIET(&opts->quiet, N_("suppress progress reporting")),
 		OPT_CALLBACK_F(0, "recurse-submodules", NULL,
-			    "checkout", "control recursive updating of submodules",
-			    PARSE_OPT_OPTARG, option_parse_recurse_submodules_worktree_updater),
+			       "checkout", "control recursive updating of submodules",
+			       PARSE_OPT_OPTARG, option_parse_recurse_submodules_worktree_updater),
 		OPT_BOOL(0, "progress", &opts->show_progress, N_("force progress reporting")),
-		OPT_BOOL('m', "merge", &opts->merge, N_("perform a 3-way merge with the new branch")),
-		OPT_CALLBACK(0, "conflict", opts, N_("style"),
-			     N_("conflict style (merge, diff3, or zdiff3)"),
-			     parse_opt_conflict),
 		OPT_END()
 	};
 	struct option *newopts = parse_options_concat(prevopts, options);
@@ -1976,6 +1972,10 @@ int cmd_checkout(int argc,
 		OPT_BOOL(0, "guess", &opts.dwim_new_local_branch,
 			 N_("second guess 'git checkout <no-such-branch>' (default)")),
 		OPT_BOOL(0, "overlay", &opts.overlay_mode, N_("use overlay mode (default)")),
+		OPT_BOOL('m', "merge", &opts.merge, N_("perform a 3-way merge with the new branch")),
+		OPT_CALLBACK(0, "conflict", &opts, N_("style"),
+			     N_("conflict style (merge, diff3, or zdiff3)"),
+			     parse_opt_conflict),
 		OPT_END()
 	};
 
@@ -2026,6 +2026,10 @@ int cmd_switch(int argc,
 			 N_("second guess 'git switch <no-such-branch>'")),
 		OPT_BOOL(0, "discard-changes", &opts.discard_changes,
 			 N_("throw away local modifications")),
+		OPT_BOOL(0, "merge", &opts.merge, N_("perform a 3-way merge with the new branch")),
+		OPT_CALLBACK(0, "conflict", &opts, N_("style"),
+			     N_("conflict style (merge, diff3, or zdiff3)"),
+			     parse_opt_conflict),
 		OPT_END()
 	};
 
@@ -2060,12 +2064,16 @@ int cmd_restore(int argc,
 		OPT_STRING('s', "source", &opts.from_treeish, "<tree-ish>",
 			   N_("which tree-ish to checkout from")),
 		OPT_BOOL('S', "staged", &opts.checkout_index,
-			   N_("restore the index")),
+			 N_("restore the index")),
 		OPT_BOOL('W', "worktree", &opts.checkout_worktree,
-			   N_("restore the working tree (default)")),
+			 N_("restore the working tree (default)")),
 		OPT_BOOL(0, "ignore-unmerged", &opts.ignore_unmerged,
 			 N_("ignore unmerged entries")),
 		OPT_BOOL(0, "overlay", &opts.overlay_mode, N_("use overlay mode")),
+		OPT_BOOL(0, "merge", &opts.merge, N_("perform a 3-way merge with the new branch")),
+		OPT_CALLBACK(0, "conflict", &opts, N_("style"),
+			     N_("conflict style (merge, diff3, or zdiff3)"),
+			     parse_opt_conflict),
 		OPT_END()
 	};
 
-- 
2.50.1.214.ga30f80fde9
Previous: Justin ToblerNext: Junio C Hamano
Message 2 of 11 in “builtin: unmark git-switch and git-restore as experimental”
  1. 0/2 builtin: unmark git-switch and git-restore as experimentalJustin Tobler, Jul 22, 2025
  2. 1/2 builtin: remove merge short flag for switch and restoreJustin Tobler, Jul 22, 2025
  3. Junio C HamanoJul 22, 2025
  4. Justin ToblerJul 22, 2025
  5. 2/2 builtin: unmark git-switch and git-restore as experimentalJustin Tobler, Jul 22, 2025
  6. Junio C HamanoJul 22, 2025
  7. Justin ToblerJul 22, 2025
  8. Junio C HamanoJul 22, 2025
  9. Justin ToblerJul 22, 2025
  10. builtin: unmark git-switch and git-restore as experimentalJustin Tobler, Jul 28, 2025
  11. Junio C HamanoJul 28, 2025

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.