threads / discuss / 14148

how to list all files that will be comitted

Subject: how to list all files that will be comitted

## tl;dr

8 messages between Jun 25, 2008 and Jun 25, 2008.

replies: 7people: 5as markdown or json

Rhodes, Kate· Jun 25, 2008, 15:31 UTC · lore

I know ls-files is the tool I need but I haven't been able to figure out what combination of options will give me the files that have been added to the index.

-Kate
Ian Hilt· Jun 25, 2008, 15:57 UTC · re: Rhodes, Kate · lore

Re: how to list all files that will be comitted

On Wed, 25 Jun 2008 at 11:31am -0400, Rhodes, Kate wrote:
Show 5 quoted lines
> I know ls-files is the tool I need but I haven't been able to figure out what
> combination of options will give me the files that have been added to the
> index.
> 
> -Kate

Have you tried "git status" ? It will output something similar to the following:

# On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: somefile # # Changed but not updated: # (use "git add <file>..." to update what will be committed) # # modified: anotherfile #

-- 
Ian Hilt
Ian.Hilt (at) gmx.com
GnuPG key: 0x4AFC1EE3
Rhodes, Kate· Jun 25, 2008, 16:01 UTC · re: Ian Hilt · lore

Re: how to list all files that will be comitted

yeah, but i was hoping for plumbing, not porcelain, that showed just what i wanted so that i didn't have to parse status' output.

-Kate
On Jun 25, 2008, at 11:57 AM, Ian Hilt wrote:
> Have you tried "git status" ?  It will output something similar to the
> following:
Karl Hasselström· Jun 25, 2008, 16:14 UTC · re: Rhodes, Kate · lore

Re: how to list all files that will be comitted

On 2008-06-25 12:01:49 -0400, Rhodes, Kate wrote:
> yeah, but i was hoping for plumbing, not porcelain, that showed just
> what i wanted so that i didn't have to parse status' output.

Unless you want a listing of all the files in the index, you probably want to call diff-index.

  git diff-index --cached <tree-ish>

gives you the diff between the index and a tree-ish. With the --name-only option, you get only the filenames and not all the modes, blob sha1s, etc.

-- 
Karl Hasselström, kha@treskal.com
      www.treskal.com/kalle
Rhodes, Kate· Jun 25, 2008, 16:16 UTC · re: Karl Hasselström · lore

Re: how to list all files that will be comitted

Perfect, exactly what I wanted. Thanks.
-Kate
On Jun 25, 2008, at 12:14 PM, Karl Hasselström wrote:
Show 17 quoted lines
> On 2008-06-25 12:01:49 -0400, Rhodes, Kate wrote:
>
>> yeah, but i was hoping for plumbing, not porcelain, that showed just
>> what i wanted so that i didn't have to parse status' output.
>
> Unless you want a listing of all the files in the index, you probably
> want to call diff-index.
>
>  git diff-index --cached <tree-ish>
>
> gives you the diff between the index and a tree-ish. With the
> --name-only option, you get only the filenames and not all the modes,
> blob sha1s, etc.
>
> -- 
> Karl Hasselström, kha@treskal.com
>      www.treskal.com/kalle
Ian Hilt· Jun 25, 2008, 16:24 UTC · re: Rhodes, Kate · lore

Re: how to list all files that will be comitted

On Wed, 25 Jun 2008 at 12:01pm -0400, Rhodes, Kate wrote:
> yeah, but i was hoping for plumbing, not porcelain, that showed just what i
> wanted so that i didn't have to parse status' output.

I wasn't able to make "git ls-files" do what you want. However, "git diff --name-only --cached" did. It's still porcelain, but it does what you want :)

-- 
Ian Hilt
Ian.Hilt (at) gmx.com
GnuPG key: 0x4AFC1EE3
Reece Dunn· Jun 25, 2008, 16:14 UTC · re: Rhodes, Kate · lore

Re: how to list all files that will be comitted

2008/6/25 Rhodes, Kate <masukomi@gmail.com>:
Show 5 quoted lines
> I know ls-files is the tool I need but I haven't been able to figure out
> what combination of options will give me the files that have been added to
> the index.
>
> -Kate

`git status` will do this, unless you need to do additional processing on the results.

HTH,
- Reece
Michael J Gruber· Jun 25, 2008, 16:19 UTC · re: Rhodes, Kate · lore

Re: how to list all files that will be comitted

Rhodes, Kate venit, vidit, dixit 25.06.2008 17:31:
> I know ls-files is the tool I need but I haven't been able to figure  
> out what combination of options will give me the files that have been  
> added to the index.
I don't think git ls-files does that, but
git diff --cached --name-only
will.

Cheers, Michael

← back to recent threads