views:

1055

answers:

2

I would like to see a list of files modified since the last commit, as 'git status' shows, but I care only about files located in a single directory. Is there a way to do this? I tried 'git status <directory>', but it seems this does something completely different (lists all changed files, as they would be if I wrote 'git add <directory>' first).

The documentation for git-status doesn't tell much, apart from the fact that it accepts the same options that git-commit does (but git-commit's purpose isn't to show lists of changed files...).

+1  A: 

Simplest solution:

  1. Go to the directory
  2. git status | grep -v '\.\.\/'

Of course this discards colors.

Can Berk Güder
+6  A: 

The reason that git status takes the same options as git commit is that the purpose of git status is to show what would happen if you committed with the same options as you passed to git status. In this respect git status is really git commit --preview.

To get what you want, you could do this which shows staged changes:

git diff --stat --cached -- <directory_of_interest>

and this, which shows unstaged changes:

git diff --stat -- <directory_of_interest>

or this which shows both:

git diff --stat HEAD -- <directory_of_interest>
Charles Bailey
This partially works, although it doesn't show newly created (untracked) files, like git-status does...
Psionides
OK, I wasn't sure what reports you needed. If you need to check for unstaged files try `git ls-files --others <directory_in_question>` or `ls-files -o`.
Charles Bailey