Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GIT: Changed File Names With Certain Extension

When I want to get a list of the files I have changed so for, I use this command:

git diff --name-only

But many times, I get many files that I don't care about right now. For example, if I am uploading to my PHP server, I usually just want the list of .php files. I tried this:

git diff --name-only **/*.php

But unfortunately, it only shows me files in the first sub-directory. So looks like it is not interpreting the double star as recursive.

Any idea?

like image 987
Rafid Avatar asked Dec 04 '22 23:12

Rafid


2 Answers

just leverage grep:

git diff --name-only | grep .php
like image 113
Adam Dymitruk Avatar answered Dec 11 '22 12:12

Adam Dymitruk


git diff --name-only '**/*.php'

(note the quotes)

Edit

Most POSIX shells don't support that pattern. From your comment, I gather that git doesn't either (I cannot test right now).

A workaround could be

git diff --name-only $(find . -name \*.php)
like image 42
cadrian Avatar answered Dec 11 '22 11:12

cadrian