I would like to know how to make git list all changed files
I'll start with laying out an example situation for my question.
Say I have changed the following files:
Uncommitted changes
/site/main.php
/site/main.html
/site/includes/lib.php
Commit 3
Commit message: "Bug xyz: Made some changes"
/site/main.php
/site/main.html
/site/main.js
/test/test.php
/test/test.html
Commit 2
Commit message: "Bug xyz: Made some more changes"
/site/main.php
/site/main.html
/site/includes/include.php
Commit 1
Commit message: "Bug abc: Note that this is another bug"
/site/login.php
Say I'm still working on bug xyz. Now I need a list of all php files that have been changed so far in the site directory for this bug. So I would need the following list as output:
/site/main.php
/site/includes/lib.php
/site/includes/include.php
What command can do this?
This is close:
git log --grep=xyz -- '*.php'
The --grep
argument is applied to the commit messages. The single quotes on the files argument ensures that git
does the expansion.
A test:
ebg@ebg(328)$ git log --oneline
f687708 bar x, y, not a
dfb4b96 foo d, e, f
df18118 foo a, b, c
ebg@ebg(329)$ git log --oneline --grep=a
f687708 bar x, y, not a
df18118 foo a, b, c
ebg@ebg(330)$ git log --oneline --grep=a -- 'a.*'
df18118 foo a, b, c
The file expansion might need something to handle subdirectories. Sort of:
git log --oneline --grep=a -- '*/a.*' 'a.*'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With