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

[PATCH/RFC v3 00/14] Introduce new commands switch-branch and restore-files

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Nov 29, 2018, 21:58 UTC
Message-ID
<20181129215850.7278-1-pclouds@gmail.com>
In-Reply-To
<20181127165211.24763-1-pclouds@gmail.com>

v3 sees switch-branch go back to switch-branch (in v2 it was checkout-branch). checkout-files is also renamed restore-files (v1 was restore-paths). Hopefully we won't see another rename.

I'll try to summarize the differences between the new commands and 'git checkout' down here, but you're welcome to just head to 07/14 and read the new man pages.

'git switch-branch'
- does not "do nothing", you have to either switch branch, create a
  new branch, or detach. "git switch-branch" with no arguments is
  rejected.
- implicit detaching is rejected. If you need to detach, you need to
  give --detach. Or stick to 'git checkout'.
- -b/-B is renamed to -c/-C with long option names
- of course does not accept pathspec
'git restore-files'
- takes a ref from --from argument, not as a free ref. As a result,
  '--' is no longer needed. All non-option arguments are pathspec
- pathspec is mandatory, you can't do "git restore-files" without any
  pathspec.
- I just remember -p which is allowed to take no pathspec :( I'll fix
  it later.
- Two more fancy features (the "git checkout --index" being the
  default mode and the backup log for accidental overwrites) are of
  course still missing. But they are coming.

I did not go replace "detached HEAD" with "unnamed branch" (or "no branch") everywhere because I think a unique term is still good to refer to this concept. Or maybe "no branch" is good enough. I dunno.

Nguyễn Thái Ngọc Duy (14):
  git-checkout.txt: fix one syntax line
  git-checkout.txt: split detached head section out
  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 into switch-branch and restore-files
  switch-branch: better names for -b and -B
  switch-branch: stop accepting pathspec
  switch-branch: reject "do nothing" case
  switch-branch: only allow explicit detached HEAD
  restore-files: take tree-ish from --from option instead
  restore-files: make pathspec mandatory
  doc: promote "git switch-branch" and "git restore-files"
 .gitignore                             |   2 +
 Documentation/config/advice.txt        |  10 +-
 Documentation/config/checkout.txt      |   5 +-
 Documentation/detach-head.txt          | 132 +++++++++
 Documentation/git-branch.txt           |   8 +-
 Documentation/git-check-ref-format.txt |   2 +-
 Documentation/git-checkout.txt         | 140 +--------
 Documentation/git-format-patch.txt     |   2 +-
 Documentation/git-merge-base.txt       |   2 +-
 Documentation/git-rebase.txt           |   2 +-
 Documentation/git-remote.txt           |   2 +-
 Documentation/git-rerere.txt           |  10 +-
 Documentation/git-reset.txt            |  18 +-
 Documentation/git-restore-files.txt    | 167 +++++++++++
 Documentation/git-revert.txt           |   2 +-
 Documentation/git-stash.txt            |   6 +-
 Documentation/git-switch-branch.txt    | 289 +++++++++++++++++++
 Documentation/gitattributes.txt        |   2 +-
 Documentation/gitcli.txt               |   4 +-
 Documentation/gitcore-tutorial.txt     |  18 +-
 Documentation/giteveryday.txt          |  24 +-
 Documentation/githooks.txt             |   5 +-
 Documentation/gittutorial-2.txt        |   2 +-
 Documentation/gittutorial.txt          |   4 +-
 Documentation/revisions.txt            |   2 +-
 Documentation/user-manual.txt          |  54 ++--
 Makefile                               |   2 +
 advice.c                               |  11 +-
 builtin.h                              |   2 +
 builtin/checkout.c                     | 380 ++++++++++++++++++-------
 command-list.txt                       |   4 +-
 git.c                                  |   2 +
 parse-options-cb.c                     |  16 ++
 parse-options.h                        |   3 +-
 sha1-name.c                            |   2 +-
 wt-status.c                            |   2 +-
 36 files changed, 1006 insertions(+), 332 deletions(-)
 create mode 100644 Documentation/detach-head.txt
 create mode 100644 Documentation/git-restore-files.txt
 create mode 100644 Documentation/git-switch-branch.txt
-- 
2.20.0.rc1.380.g3eb999425c.dirty
Previous: Junio C HamanoNext: Nguyễn Thái Ngọc Duy
Message 53 of 110 in “checkout: print something when checking out paths”
  1. checkout: print something when checking out pathsNguyễn Thái Ngọc Duy, Nov 10, 2018
  2. Junio C HamanoNov 12, 2018
  3. Duy NguyenNov 12, 2018
  4. Junio C HamanoNov 12, 2018
  5. Ævar Arnfjörð BjarmasonNov 19, 2018
  6. Duy NguyenNov 19, 2018
  7. Junio C HamanoNov 20, 2018
  8. [RFC] Introduce two new commands, switch-branch and restore-pathsDuy Nguyen, Nov 20, 2018
  9. Thomas GummererNov 25, 2018
  10. Junio C HamanoNov 26, 2018
  11. Duy NguyenNov 26, 2018
  12. Ævar Arnfjörð BjarmasonNov 26, 2018
  13. Duy NguyenNov 26, 2018
  14. Stefan BellerNov 26, 2018
  15. Junio C HamanoNov 27, 2018
  16. 0/7 Introduce new commands switch-branch and checkout-filesNguyễn Thái Ngọc Duy, Nov 27, 2018
  17. 1/7 parse-options: allow parse_options_concat(NULL, options)Nguyễn Thái Ngọc Duy, Nov 27, 2018
  18. Stefan BellerNov 27, 2018
  19. Duy NguyenNov 28, 2018
  20. Junio C HamanoNov 28, 2018
  21. 2/7 checkout: make "opts" in cmd_checkout() a pointerNguyễn Thái Ngọc Duy, Nov 27, 2018
  22. 5/7 checkout: split options[] array in three piecesNguyễn Thái Ngọc Duy, Nov 27, 2018
  23. Junio C HamanoNov 29, 2018
  24. 6/7 checkout: split into switch-branch and checkout-filesNguyễn Thái Ngọc Duy, Nov 27, 2018
  25. Junio C HamanoNov 28, 2018
  26. Duy NguyenNov 28, 2018
  27. Stefan BellerNov 28, 2018
  28. Duy NguyenNov 28, 2018
  29. Junio C HamanoNov 29, 2018
  30. Stefan XenosNov 28, 2018
  31. Stefan XenosNov 28, 2018
  32. Stefan XenosNov 28, 2018
  33. Junio C HamanoNov 29, 2018
  34. Duy NguyenNov 29, 2018
  35. Duy NguyenNov 29, 2018
  36. Stefan BellerNov 29, 2018
  37. Duy NguyenNov 29, 2018
  38. Stefan XenosNov 29, 2018
  39. 4/7 checkout: move dwim_new_local_branch to checkout_optsNguyễn Thái Ngọc Duy, Nov 27, 2018
  40. Stefan BellerNov 27, 2018
  41. 7/7 Suggest other commands instead of "git checkout"Nguyễn Thái Ngọc Duy, Nov 27, 2018
  42. Junio C HamanoNov 28, 2018
  43. Duy NguyenNov 28, 2018
  44. Junio C HamanoNov 29, 2018
  45. 3/7 checkout: move 'confict_style' to checkout_optsNguyễn Thái Ngọc Duy, Nov 27, 2018
  46. Stefan BellerNov 27, 2018
  47. Duy NguyenNov 28, 2018
  48. Duy NguyenNov 28, 2018
  49. Stefan BellerNov 28, 2018
  50. Duy NguyenNov 29, 2018
  51. Stefan BellerDec 3, 2018
  52. Junio C HamanoNov 30, 2018
  53. 00/14 Introduce new commands switch-branch and restore-filesNguyễn Thái Ngọc Duy, Nov 29, 2018
  54. 01/14 git-checkout.txt: fix one syntax lineNguyễn Thái Ngọc Duy, Nov 29, 2018
  55. 03/14 checkout: factor out some code in parse_branchname_arg()Nguyễn Thái Ngọc Duy, Nov 29, 2018
  56. 04/14 checkout: make "opts" in cmd_checkout() a pointerNguyễn Thái Ngọc Duy, Nov 29, 2018
  57. 05/14 checkout: move 'confict_style' and 'dwim_..' to checkout_optsNguyễn Thái Ngọc Duy, Nov 29, 2018
  58. 06/14 checkout: split options[] array in three piecesNguyễn Thái Ngọc Duy, Nov 29, 2018
  59. 08/14 switch-branch: better names for -b and -BNguyễn Thái Ngọc Duy, Nov 29, 2018
  60. 09/14 switch-branch: stop accepting pathspecNguyễn Thái Ngọc Duy, Nov 29, 2018
  61. 10/14 switch-branch: reject "do nothing" caseNguyễn Thái Ngọc Duy, Nov 29, 2018
  62. 11/14 switch-branch: only allow explicit detached HEADNguyễn Thái Ngọc Duy, Nov 29, 2018
  63. Eckhard MaaßMar 10, 2019
  64. Duy NguyenMar 11, 2019
  65. 12/14 restore-files: take tree-ish from --from option insteadNguyễn Thái Ngọc Duy, Nov 29, 2018
  66. 13/14 restore-files: make pathspec mandatoryNguyễn Thái Ngọc Duy, Nov 29, 2018
  67. 14/14 doc: promote "git switch-branch" and "git restore-files"Nguyễn Thái Ngọc Duy, Nov 29, 2018
  68. 07/14 checkout: split into switch-branch and restore-filesNguyễn Thái Ngọc Duy, Nov 29, 2018
  69. Elijah NewrenDec 4, 2018
  70. Junio C HamanoDec 4, 2018
  71. Duy NguyenDec 4, 2018
  72. Elijah NewrenDec 4, 2018
  73. Duy NguyenDec 4, 2018
  74. Junio C HamanoDec 5, 2018
  75. Elijah NewrenDec 5, 2018
  76. Junio C HamanoDec 5, 2018
  77. Junio C HamanoDec 5, 2018
  78. Elijah NewrenDec 5, 2018
  79. 02/14 git-checkout.txt: split detached head section outNguyễn Thái Ngọc Duy, Nov 29, 2018
  80. Ævar Arnfjörð BjarmasonNov 29, 2018
  81. Ævar Arnfjörð BjarmasonNov 29, 2018
  82. Dan FabulichNov 29, 2018
  83. Dan FabulichNov 30, 2018
  84. Duy NguyenNov 30, 2018
  85. Duy NguyenNov 30, 2018
  86. Junio C HamanoNov 30, 2018
  87. Ævar Arnfjörð BjarmasonNov 30, 2018
  88. Duy NguyenNov 30, 2018
  89. Junio C HamanoNov 30, 2018
  90. Duy NguyenNov 30, 2018
  91. Junio C HamanoNov 30, 2018
  92. Thomas GummererDec 2, 2018
  93. Junio C HamanoDec 2, 2018
  94. Elijah NewrenDec 4, 2018
  95. Duy NguyenDec 4, 2018
  96. Elijah NewrenDec 4, 2018
  97. Duy NguyenDec 4, 2018
  98. Elijah NewrenDec 4, 2018
  99. Duy NguyenDec 4, 2018
  100. Eric SunshineDec 4, 2018
  101. checkout: print something when checking out pathsNguyễn Thái Ngọc Duy, Nov 13, 2018
  102. Junio C HamanoNov 14, 2018
  103. Duy NguyenNov 14, 2018
  104. Junio C HamanoJan 28, 2019
  105. Duy NguyenJan 29, 2019
  106. 0/2 nd/checkout-noisy updatesNguyễn Thái Ngọc Duy, Feb 6, 2019
  107. 1/2 checkout: update count-checkouts messagesNguyễn Thái Ngọc Duy, Feb 6, 2019
  108. 2/2 checkout: count and print -m paths separatelyNguyễn Thái Ngọc Duy, Feb 6, 2019
  109. Stefan XenosNov 28, 2018
  110. Junio C HamanoNov 29, 2018

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.