git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git worktree fails to recreate existing branch even with -B
@ 2016-02-09 14:54 Kirill Likhodedov
  2016-02-15  9:41 ` Duy Nguyen
  0 siblings, 1 reply; 6+ messages in thread
From: Kirill Likhodedov @ 2016-02-09 14:54 UTC (permalink / raw)
  To: git

Git doesn’t allow me to execute 
    git worktree add -B <branch> <path> <start-point>
where <branch> already exists in the repository.

The command prints the following:
    Preparing <path> (identifier <branch>)
    fatal: Refusing to point HEAD outside of refs/

I’m trying to create a worktree on an existing branch <branch>, which should point to <start-point>. This obviously should fail with “-b”, but I use “-B” and expect it to be reset to <start-point> as mentioned in the docs:

    By default, -b refuses to create a new branch if it already exists.  
    -B overrides this safeguard, resetting <new-branch> to <branch>.

Do I miss something or there is a bug?

Steps to reproduce:

git init wt
cd wt
echo 'asd' > a.txt ; git add a.txt ; git commit -m initial
git branch br1
git worktree add -B br1 ~/temp/br1 master

Error message:
Preparing /Users/loki/temp/br1 (identifier br1)
fatal: Refusing to point HEAD outside of refs/

Thanks a lot!
-- Kirill

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-02-16  1:15 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-02-09 14:54 git worktree fails to recreate existing branch even with -B Kirill Likhodedov
2016-02-15  9:41 ` Duy Nguyen
2016-02-15 13:35   ` [PATCH 1/2] worktree: fix "add -B" Nguyễn Thái Ngọc Duy
2016-02-15 13:35     ` [PATCH 2/2] worktree add -B: do the checkout test before update branch Nguyễn Thái Ngọc Duy
2016-02-15 23:53     ` [PATCH 1/2] worktree: fix "add -B" Junio C Hamano
2016-02-16  1:15       ` Duy Nguyen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).