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

Re: Suggestion: git status --untracked

From
Jakub Narebski <jnareb@gmail.com>
Date
Feb 11, 2008, 10:56 UTC
Message-ID
<m3bq6ng3sb.fsf@localhost.localdomain>
In-Reply-To
<b77c1dce0802110146o708e26a7lef56683f6b823365@mail.gmail.com>
"Rafael Garcia-Suarez" <rgarciasuarez@gmail.com> writes:
> I find myself wanting sometimes to filter out the output of
> git-status, to feed it to another command (for example, git-add, or
> rm, or cat >> .gitignore). However it's not currently very easy to
> parse in a one-liner.
Probably because git-status is porcelain, and is meant to be used by
end user, not in scripts.
 
Show 8 quoted lines
> I'm suggesting to add options to control this behaviour. My suggestion
> would be (for a start) to add an option --untracked that will list all
> untracked files on stdout, without a leading "#\t", and without
> listing the added / modified / removed files.
> 
> I'm willing to implement it, but I'd like to have some discussion
> about the interface first. Is that a good idea at all, and how could
> it be improved interface-wise?

To list all untracked files you can use plumbing command, namely "git ls-files --others" (Show other files in the output), or perhaps "git ls-files -o --directory --no-empty-directory --exclude-standard"

If you want to use git command in script, it is better to find appropriate plumbing command to do what you want, for example git-ls-files instead of git-status to list untracked files, git-symbolic-ref instead of git-branch to get current branch name, etc.

-- 
Jakub Narebski
Poland
ShadeHawk on #git
Previous: Jeff King
Message 5 of 5 in “Suggestion: git status --untracked”
  1. Rafael Garcia-SuarezFeb 11, 2008
  2. Matthieu MoyFeb 11, 2008
  3. Rafael Garcia-SuarezFeb 11, 2008
  4. Jeff KingFeb 11, 2008
  5. Jakub NarebskiFeb 11, 2008

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.