Skip to contentSkip to conversation

misleading "man git-worktree", is last "add" argument necessarily a "branch"?

DISCUSSION Robert P. J. Day 3 participants 4 messages Jan 17, 2018

lore
Share & tools
lore
#0 lore raw

perusing "git worktree", and man page reads:

  SYNOPSIS
       git worktree add [-f] [--detach] [--checkout] [--lock]   \
                        [-b <new-branch>] <path> [<branch>]
                                                 ^^^^^^^^^^

however, can't that last optional argument be any arbitrary commit, not just a "branch"?

rday

#1 lore raw
Quoted 10 lines · Robert P. J. Day

perusing "git worktree", and man page reads:

  SYNOPSIS
       git worktree add [-f] [--detach] [--checkout] [--lock]   \
                        [-b <new-branch>] <path> [<branch>]
                                                 ^^^^^^^^^^

however, can't that last optional argument be any arbitrary commit, not just a "branch"?

It's been changed to commit-ish about two months ago in c4738aedc0 (worktree: add can be created from any commit-ish - 2017-11-26)

Signature · 1 line
Duy
#2 lore raw
Quoted 9 lines · Duy Nguyen
Quoted 8 lines · Robert P. J. Day

perusing "git worktree", and man page reads:

  SYNOPSIS
       git worktree add [-f] [--detach] [--checkout] [--lock]   \
                        [-b <new-branch>] <path> [<branch>]
                                                 ^^^^^^^^^^
Quoted 5 lines
Quoted 2 lines

however, can't that last optional argument be any arbitrary commit, not just a "branch"?

It's been changed to commit-ish about two months ago in c4738aedc0 (worktree: add can be created from any commit-ish - 2017-11-26)

guess i better update my repo, thanks.

rday

#3 lore raw

Re* misleading "man git-worktree", is last "add" argument necessarily a "branch"?

In reply to Duy Nguyen
Quoted 9 lines · Duy Nguyen
Quoted 8 lines · Robert P. J. Day

perusing "git worktree", and man page reads:

  SYNOPSIS
       git worktree add [-f] [--detach] [--checkout] [--lock]   \
                        [-b <new-branch>] <path> [<branch>]
                                                 ^^^^^^^^^^
Quoted 5 lines
Quoted 2 lines

however, can't that last optional argument be any arbitrary commit, not just a "branch"?

It's been changed to commit-ish about two months ago in c4738aedc0 (worktree: add can be created from any commit-ish - 2017-11-26)

Indeed "git worktree --help" is more up to date, but "git worktree -h" is stale.

-- >8 --
Subject: worktree: say that "add" takes an arbitrary commit in short-help

c4738aed ("worktree: add can be created from any commit-ish", 2017-11-26) taught "git worktree add" to start a new worktree with an arbitrary commit-ish checked out, not limited to a tip of a branch.

"git worktree --help" was updated to describe this, but we forgot to update "git worktree -h".

---
 builtin/worktree.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
builtin/worktree.c +1 -1
index 7cef5b120b..9efdc22466 100644
@@ -14,7 +14,7 @@
 #include "worktree.h"
 
 static const char * const worktree_usage[] = {
-	N_("git worktree add [<options>] <path> [<branch>]"),
+	N_("git worktree add [<options>] <path> [<commit-ish>]"),
 	N_("git worktree list [<options>]"),
 	N_("git worktree lock [<options>] <path>"),
 	N_("git worktree prune [<options>]"),