From: Nguyen Thai Ngoc Duy Date: Wed, 05 Oct 2011 04:02:30 GMT Subject: Re: [RFC/PATCH] Add multiple workdir support to branch/checkout Message-ID: In-Reply-To: <1317786204-57335-1-git-send-email-jaysoffian@gmail.com> On Wed, Oct 5, 2011 at 2:43 PM, Jay Soffian wrote: > When using 'git new-workdir', there is no safety mechanism to prevent the > same branch from being checked out twice, nor to prevent a checked out > branch from being deleted. > > By teaching 'checkout' to record the workdir path using > 'branch..checkout' when switching branches, we can easily check if a > branch is already checked out in another workdir before switching to that > branch. Similarly, we can now add a check before deleting a branch. > > Allow 'checkout -f' to force the checkout and issue a warning > instead of an error. > > Guard this behavior behind 'core.recordCheckouts', which we will > teach 'git new-workdir' to set in a followup commit. I've wanted to to something like this, but you beat me to it ;) Could you please consider a more generic approach? What I have in mind is a mechanism to "lock" a branch, so that only commands that have the key can update it. So instead of branch..checkout, I would have something like branch..locked = , where is just a string. Only commands that provide the matching are allowed to update the branch. In checkout case, could be "checkout: worktree". This approach addresses more cases than just multiple workdir. We could relax restrictions on pushing to a non-bare repository: we only disallow pushing to locked branches. We can also use this to prevent users from checking out another branch (by locking HEAD) while in the middle of interactive rebase/bisect/... -- Duy