path: root/Documentation
diff options
authorThomas Gummerer <>2017-11-29 20:04:50 (GMT)
committerJunio C Hamano <>2017-12-06 17:47:35 (GMT)
commit71d6682d8ca9870cbe457cf55c83402c33b41030 (patch)
tree23fe7176c9dc953f64acb55d96b852aded935a57 /Documentation
parent4e8533319760c1e9255c56c2059c721286dc8dab (diff)
worktree: add --guess-remote flag to add subcommand
Currently 'git worktree add <path>' creates a new branch named after the basename of the <path>, that matches the HEAD of whichever worktree we were on when calling "git worktree add <path>". It's sometimes useful to have 'git worktree add <path> behave more like the dwim machinery in 'git checkout <new-branch>', i.e. check if the new branch name, derived from the basename of the <path>, uniquely matches the branch name of a remote-tracking branch, and if so check out that branch and set the upstream to the remote-tracking branch. Add a new --guess-remote option that enables exactly that behaviour. Signed-off-by: Thomas Gummerer <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'Documentation')
1 files changed, 7 insertions, 0 deletions
diff --git a/Documentation/git-worktree.txt b/Documentation/git-worktree.txt
index 3044d30..2a4ea76 100644
--- a/Documentation/git-worktree.txt
+++ b/Documentation/git-worktree.txt
@@ -115,6 +115,13 @@ OPTIONS
such as configuring sparse-checkout. See "Sparse checkout"
in linkgit:git-read-tree[1].
+ With `worktree add <path>`, without `<commit-ish>`, instead
+ of creating a new branch from HEAD, if there exists a tracking
+ branch in exactly one remote matching the basename of `<path>,
+ base the new branch on the remote-tracking branch, and mark
+ the remote-tracking branch as "upstream" from the new branch.
When creating a new branch, if `<commit-ish>` is a branch,
mark it as "upstream" from the new branch. This is the