I’ve been working on a project that needs to touch basically every view (so within the app/views folder), but there’s a lot of views. Given a combination of bash and git, how can a get a list of the files I haven’t committed an edit to since a given revision?
Share
There’s probably a neater way of doing this, but I think the following works:
If the last revision before the changes was
fa1afe1, then you can find all the files that changed underapp/viewswith:Also, you can see all of the files that git is tracking under
app/viewswith:Now you can find all the lines that only appear in the output of one of those commands by using
comm -3and bash’s process substitution syntax:(You might find it clearer to send the output of the two commands to temporary files and then use
commrather than use process substitution, since then you’ll have a solution that will work with/bin/shas well and may be easier to understand.)This command will also show files that were deleted in the changes since
fa1afe1, since those files won’t appear in the output ofgit ls-files. As another caveat, strictly speaking this will just show you files which are different between that commit and now, so it will miss files that were changed in one commit and reverted back to their original content afterwards. If that’s a problem then you can usegit logwith--name-onlyand appropriate formatting to build the list of changed files instead ofgit diff.