8syvsa
2.296K
· June 2012 ·
1900150 10203074354438338 1015529188 n

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.

Sign in or sign up to add your response.