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

Re: How to list files that are pending for commit from a merge, including hand modified files

From
Brent Goodrick <bgoodr@gmail.com>
Date
Feb 22, 2009, 02:09 UTC
Message-ID
<e38bce640902211809u70c0de2el96a2df0238bc671@mail.gmail.com>
In-Reply-To
<alpine.LFD.2.00.0902211523280.3111@localhost.localdomain>

Thanks very much! I'll have to play around with those variations a bit to get a feel for what will work in my context.

bg

On Sat, Feb 21, 2009 at 3:29 PM, Linus Torvalds <torvalds@linux-foundation.org> wrote:

Show 41 quoted lines
>
>
> On Sat, 21 Feb 2009, Brent Goodrick wrote:
>>
>> Is there some way in which to get a listing of the files that git-status
>> shows in its "changes to be committed" section, but not the "Untracked
>> files" section, short of postprocessing the git-status output with
>> sed/awk gymnastics?
>
> Just do variations on
>
>        git diff --name-only HEAD
>
> and the reason I say "variations on" is that depending on exactly what you
> want you may want to use slightly different diffs.
>
> For example, the command line above will list all files that are changed
> in the working tree wrt HEAD. But if you want to see only the files that
> you have actually updated in the index (ie the ones that would be
> committed without using "-a"), you should add "--cached" to the command
> line, so that it does the diff from HEAD to index, not HEAD to working
> tree.
>
> And if you want to see what files are different in the working tree from
> the index, then drop the "HEAD" part, since that's the default behavior
> for "git diff".
>
> Finally, use "--name-status" if you want to see if they are new, modified,
> or deleted - rather than just the name.
>
> And if you care about renames, and want to see them as such, use -C or -M,
> of course.
>
> So "git ls-files" is not at all what you want. That will give you
> information about the current index, but doesn't talk at all about how it
> differs from the previous commit or from the working tree. It can be
> useful for another thing, though: if you're in the middle of a merge, then
> you can ask for which files are marked as being unmerged in the index.
>
>                Linus
>
Previous: Linus Torvalds
Message 3 of 3 in “How to list files that are pending for commit from a merge, including hand modified files”
  1. Brent GoodrickFeb 21, 2009
  2. Linus TorvaldsFeb 21, 2009
  3. Brent GoodrickFeb 22, 2009

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.