0

I need to check the git status and find all files which is not ".txt" format.

I know how to find all files which is in this format:

$TextFiles = $(git status --short *.txt --porcelain | Measure-Object | Select-Object -expand Count)

How can I do the same but to retrieve all other files with NO text format??

I've tried this way but it didn't work...

$NoTextFiles = $(git status --short -ne *.txt --porcelain | Measure-Object | Select-Object -expand Count)

1 Answer 1

1

You can use :! for your git pathspec (see gitglossary for more info)

git status --short ':!*.txt'

But when you have staged entire directories this command will only list the directory name not its content.
If you want to list every file that is not *.txt you should do this with powershell:

git status --short '*.*' | Where-Object { $_ -notmatch ".*\.txt"}
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.