List the modified files on your repository

So you're there, working for five or six hours and then, for some reason, you need a list of the files you modified. So you log them:

git whatchanged --since="6 hours ago"

But imagine you've worked around thousand files. So how do you list only the file names?

First, let's compact our output:

git whatchanged --since="6 hours ago" --format=oneline

Now, we need to get only the lines that have filenames on it, so we'll use grep for that:

git whatchanged --since="6 hours ago" --format=oneline | grep "^:"

Now let's remove all that trash and get just the filenames. For that, we'll use sed:

git whatchanged --since="6 hours ago" --format=oneline | grep "^:" | sed 's:.*[DAM][ \\''t]*\([^ \\''t]*\):\1:g'

And there you have it. The regex makes sure that only the file name is return (with a few spaces on the begginig of the line. that never bothered me but can easily be removed with another sed) and you can copy that to wherever you need it.

Filed Under

Awesome Job

31a34008 79d6 11e6 81ec 100c9f60d414
Security Analyst
South San Francisco, CA
Full Time