aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/config
diff options
context:
space:
mode:
authorJacob Abel <jacobabel@nullpo.dev>2023-05-17 21:48:52 +0000
committerJunio C Hamano <gitster@pobox.com>2023-05-17 15:55:24 -0700
commit35f0383ca61db8f0b6ee1e9002150bbb13649993 (patch)
tree781cf9a43ab2c0cd93aca231e93139f7c1ae992c /Documentation/config
parent7ab891898524abbeb2c52f3f55fcf5e2457f930b (diff)
downloadgit-35f0383ca61db8f0b6ee1e9002150bbb13649993.tar.gz
worktree add: introduce "try --orphan" hint
Add a new advice/hint in `git worktree add` for when the user tries to create a new worktree from a reference that doesn't exist. Current Behavior: % git init foo Initialized empty Git repository in /path/to/foo/ % touch file % git -C foo commit -q -a -m "test commit" % git -C foo switch --orphan norefbranch % git -C foo worktree add newbranch/ Preparing worktree (new branch 'newbranch') fatal: invalid reference: HEAD % New Behavior: % git init --bare foo Initialized empty Git repository in /path/to/foo/ % touch file % git -C foo commit -q -a -m "test commit" % git -C foo switch --orphan norefbranch % git -C foo worktree add newbranch/ Preparing worktree (new branch 'newbranch') hint: If you meant to create a worktree containing a new orphan branch hint: (branch with no commits) for this repository, you can do so hint: using the --orphan option: hint: hint: git worktree add --orphan newbranch/ hint: hint: Disable this message with "git config advice.worktreeAddOrphan false" fatal: invalid reference: HEAD % git -C foo worktree add -b newbranch2 new_wt/ Preparing worktree (new branch 'newbranch') hint: If you meant to create a worktree containing a new orphan branch hint: (branch with no commits) for this repository, you can do so hint: using the --orphan option: hint: hint: git worktree add --orphan -b newbranch2 new_wt/ hint: hint: Disable this message with "git config advice.worktreeAddOrphan false" fatal: invalid reference: HEAD % Signed-off-by: Jacob Abel <jacobabel@nullpo.dev> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'Documentation/config')
-rw-r--r--Documentation/config/advice.txt4
1 files changed, 4 insertions, 0 deletions
diff --git a/Documentation/config/advice.txt b/Documentation/config/advice.txt
index c96b5b2e5d..c548a91e67 100644
--- a/Documentation/config/advice.txt
+++ b/Documentation/config/advice.txt
@@ -138,4 +138,8 @@ advice.*::
checkout.
diverging::
Advice shown when a fast-forward is not possible.
+ worktreeAddOrphan::
+ Advice shown when a user tries to create a worktree from an
+ invalid reference, to instruct how to create a new orphan
+ branch instead.
--