Where developers come to connect, share, build and be inspired.

10

List the modified files on your repository

1585 views

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.

Comments

Add a comment