There appears to be an inconsistency in how ls-files handles --work-tree compared to how status handles --work-tree.
Context: I have a directory dotfiles.git with core.worktree = /Users/nick (my home directory; I'm on OS X Lion with MacPorts git version 1.7.10.4).
Below are the outputs of git ls-files and git status for the following options of --work-tree: 1) none (equivalent to --work-tree=/Users/nick because of core.worktree setting, right?) 2) --work-tree=~ 3) --work-tree=/Users/nick 4) --work-tree=/Users/nick. (note the period at the end)
Note that ls-files works properly with "/Users/nick." and "~", while status works properly with "/Users/nick" and none. No output is produced for "git ls-files" or "git --work-tree=/Users/nick".
$ git status # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # ../.hiya nothing added to commit but untracked files present (use "git add" to track)
$ git ls-files
$ git --work-tree=~ ls-files .bash_profile .bashrc .gemrc .profile .rvmrc .screenrc
$ git --work-tree=~ status fatal: This operation must be run in a work tree
$ git --work-tree=/Users/nick status # On branch master # Untracked files: # (use "git add <file>..." to include in what will be committed) # # ../.hiya nothing added to commit but untracked files present (use "git add" to track)
$ git --work-tree=/Users/nick ls-files
$ git --work-tree=/Users/nick. ls-files .bash_profile .bashrc .gemrc .profile .rvmrc .screenrc
$ git --work-tree=/Users/nick. status fatal: This operation must be run in a work tree