tags:

views:

245

answers:

3

When I do git status in a subfolder of my repository it includes the status of parent folders also.

Is there a way to constrain git-status to just a particular folder?

A: 

When I tried git, I didn't find a way to do that.

I ended up doing:

x@x:~/x$ git status
# On branch master
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#       b
#       main/a
nothing added to commit but untracked files present (use "git add" to track)

x@x:~/x$ git status | grep main
#       main/a
Macarse
This is the method I was using... the following also gets the status headings: git status |grep "main\|:\$" ... unfortunately you lose colouring.
EoghanM
+2  A: 

Some plumbing commands do take a directory as parameter:

git ls-files -t -o -m aDirectory

would give you all files changed but not updated (not added to stage), or untracked. And that for a directory.

As written in this thread, git ls-files does not support a '--added option.

more fundamental reason is because ls-files plumbing is about the index.
Added is not about comparison between the index and the work tree.
It is between the HEAD commit and the index, and it does not belong to ls-files plumbing.

So, using commands mentioned here:

git diff-index --name-only -B -R -M -C HEAD src

would give you both non-added and added files

git diff-files --name-only -B -R -M -C src

would give you only non-added files. (while detecting rewrites, renames, copies, ...)

As usual with plumbing commands, some scripting is in order ;)

VonC
A: 

Imperfect, but this works as well from within the the directory you are interested in:

git stats | grep -v ' \.\./'

That will hide all directories that would require an upward reference in their relative path.

If you want to get color spitting out the other end, set color.status to always:

git config color.status always
Marcus Griep