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

git ls-files --error-unmatch weirdness

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Aug 12, 2011, 13:24 UTC
Message-ID
<20110812132436.GA12147@goldbirke>
Hi,
I was looking for untracked files when noticed this:
repo$ git init
Initialized empty Git repository in /home/szeder/tmp/git/repo/.git/
repo (master)$ mkdir dir
repo (master)$ touch dir/file
repo (master)$ git add dir/file
repo (master)$ git commit -m 'first'
[master (root-commit) 2c0990c] first
 0 files changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 dir/file
repo (master)$ git ls-files --others --error-unmatch
repo/dir (master)$ echo $?
0
repo (master)$ cd dir
repo/dir (master)$ git ls-files --others --error-unmatch
error: pathspec '' did not match any file(s) known to git.
Did you forget to 'git add'?
repo/dir (master)$ echo $?
1

So, the same 'git ls-files' command is OK when run at the top of the worktree, but errors out in a subdirectory. What's going on? Is this a bug? If not, why not?

Thanks, Gábor

Next: Nguyen Thai Ngoc Duy
Message 1 of 3 in “git ls-files --error-unmatch weirdness”
  1. SZEDER GáborAug 12, 2011
  2. Nguyen Thai Ngoc DuyAug 12, 2011
  3. Junio C HamanoAug 12, 2011

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.