In my remote repository there are 3 branches (master and 2 long running branches):
master #the common features are here like Core, DAL,...
north #customized f
In addition of git worktree add --checkout
, Git 2.16 (Q1 2018) will propose another alternative:
The way "git worktree add
" determines what branch to create from where and checkout in the new worktree has been updated a bit.
See commit e92445a, commit 71d6682 (29 Nov 2017), and commit 4e85333, commit e284e89, commit c4738ae, commit 7c85a87 (26 Nov 2017) by Thomas Gummerer (tgummerer).
(Merged by Junio C Hamano -- gitster -- in commit 66d3f19, 19 Dec 2017)
add
worktree.guessRemote
config optionSome users might want to have the
--guess-remote
option introduced in the previous commit on by default, so they don't have to type it out every time they create a new worktree.Add a config option
worktree.guessRemote
that allows users to configure the default behaviour for themselves.
The documentation for git config now reads:
worktree.guessRemote::
With
add
, if no branch argument, and neither of-b
nor-B
nor--detach
are given, the command defaults to creating a new branch from HEAD.
Ifworktree.guessRemote
is set to true,worktree add
tries to find a remote-tracking branch whose name uniquely matches the new branch name.
- If such a branch exists, it is checked out and set as "upstream" for the new branch.
- If no such match can be found, it falls back to creating a new branch from the current HEAD.
Actually, Git 2.21 (Q1 2019) clarifies the documentation for this option, which jumped right in with "With add
", without explaining that add
is a sub-command of "git worktree".
See commit b4583d5 (23 Dec 2018) by Eric Sunshine (sunshineco).
(Merged by Eric Sunshine -- sunshineco -- in commit b4583d5, 28 Dec 2018)
The documentation now reads:
worktree.guessRemote
:If no branch is specified and neither
-b
nor-B
nor--detach
is used, thengit worktree add
defaults to creating a new branch from HEAD.