git/list[1] front-page[2] threads[3] people[4] search[5] about
 

git worktrees must exist even if locked

From
TDtaylor, david <david.taylor@dell.com>
Date
May 10, 2017, 20:24 UTC
Message-ID
<63F1AEE13FAE864586D589C671A6E18B0D5F2C@MX203CL03.corp.emc.com>

The Git documentation in describing worktrees says that one reason why you might want to lock a worktree is to prevent it from being pruned if it is on a removable media that isn't currently mounted.

So, my expectation was that if the worktree is inaccessible (and locked), Git would pretend that there is no worktree by that name.

In reality, if you have such a worktree, Git gets an error.
 On local systems, /home is local to a machine; home directories are elsewhere.
Home directories are NFS mounted; /home is not.
. create a repository in /my/home/dir/my-repo.git with
    git clone --bare <some arguments>
. create an empty directory /home/somedir/worktree-tests
. use 'git worktree add' to add /home/somedir/worktree-tests/<branch-name>
  as a worktree on branch <branch-name>.  It gets populated with the correct
  content.
. lock it using'git worktree lock'

So far, so good. Now, go to a different computer -- one on which /home/somedir/worktree-tests does not exist (and therefore /home/somedir/worktree-tests/<branch-name> does not exist).

. cd /my/home/dir/my-repo.git
Now, try issuing Git commands.  Many will fail.
  git fetch ==> fails:
  fatal: Invalid path '/home/somedir/worktree-tests': No such file or directory
  git status ==> fails -- same error as above
  git help worktree ==> fails -- same error as above
Next: Duy Nguyen
Message 1 of 2 in “git worktrees must exist even if locked”
  1. taylor, davidMay 10, 2017
  2. Duy NguyenMay 29, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.