Today I Learned

hashrocket A Hashrocket project

List Commits That Change a File

Today I'm wrapping a PR with a large Git rebase. There are many commits on my branch that change the same file (.circleci/config.yml) and aren't valuable on their own. In the end, I want them all squashed into a single commit. The challenge is that I changed other files in between; it's kind of a mess. How can I squash the branch down to something manageable?

One technique is to view just changes to my file:

$ git log --follow --oneline .circleci/config.yml

c9f7108 Try to decode file before unzipping
87c8092 Quick push
327d419 Try this!

Using this list, I can execute a rebase that just squashes the commits that touch the file, leaving everything else intact.

See More #git TILs