Skip to content

teach git-checkout -B WAS builtin/checkout: DWIM with -f -b

Tay Ray Chuan git 1 version New

Get series with b4
b4 am [email protected]

Versions newest first

  1. v2 Latest3 patches 0 repliesNew

Changes in v2 from the cover letter

- reworked option handling
- don't replace <new_branch> with <branch> in documentation

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3add tests for checkout -bt/t2018-checkout-branch.sh+121 -00 replies
2/3builtin/checkout: reword hint for -bbuiltin/checkout.c+2 -10 replies
3/3builtin/checkout: learn -BDocumentation/git-checkout.txt builtin/checkout.c t/t2018-checkout-branch.sh+88 -70 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/3] teach git-checkout -B WAS builtin/checkout: DWIM with -f -b

Right now, the -f/--force in git-checkout doesn't carry over to -b operations - ie. you can't do git checkout -b branch on an existing branch.

This patch allows you to do this with the -B option, so that one can do

git checkout -B branch ref

which is equivalent to

git branch -f branch ref && git checkout branch

Changes from v1:
- reworked option handling
- don't replace <new_branch> with <branch> in documentation

Contents:
[PATCH v2 1/3] add tests for checkout -b [PATCH v2 2/3] builtin/checkout: reword hint for -b [PATCH v2 3/3] builtin/checkout: learn -B

 Documentation/git-checkout.txt |   21 +++++-
 builtin/checkout.c             |   32 ++++++--
 t/t2018-checkout-branch.sh     |  166 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 211 insertions(+), 8 deletions(-)
 create mode 100755 t/t2018-checkout-branch.sh