Advanced filtering in Git commands

⚡ TL;DR You can use negative filters like git diff ':!*.lock' git status ':!*.lock' and on attributes: git status ':(attr:!linguist-generated !linguist-vendored)' You can even combine those patterns. Excluding on a glob I sometimes have many changes over multiple files in a Git repository. And then I want to display only the changes made to files in the src/ directory: git diff '*/src/*' Or, more interesting, I want all changes except those made to lock files: ...

May 4, 2026 · 2 min

My Commits and Tags Are Now Signed

Announcement I’m now signing my git commit and tags with an SSH key. Details of the fingerprint can be found in the security document. It says that commit after 2024-01-01 are going to be signed, because I’m starting now on one machine and I will propagate the configuration over the next few days to other machines. Why Why bother with cryptographic signatures? Anyone can pretend to be me. They just need to write my name and email in the author fields of a commit message. However1, I’m the only one able to produce signatures with that particular public key. This will help to check that I’m actually the author of the commits and tags you rely on when using my code. ...

December 29, 2023 · 3 min

Quick Git Commit Amend

Sometimes when your pull request is reviewed, it turns out that you have to make a small change. For instance, you have to remove a white space. Here is a really quick way to fix it, that will not even fire your editor to change the commit message. Make sure you are on the branch of the pull request (for instance, by reading the output of git status) Edit and save your file, removing the white space. Then in your terminal, use: git commit --amend -a -v -C HEAD This edits (--amend) your last commit, adding all the changes made to files (-a) and reusing the last commit message (-C HEAD). Once this is done, a summary is printed (-v). You can now push your changes with: git push --force-with-lease We need --force-with-lease to “confirm to the server that we really want to edit the last commit”. Caution Two words of caution with this technique: ...

November 21, 2021 · 2 min

Git ls-files is Faster Than Fd and Find

The git ls-files command is up to 5 times faster than fd or find. But why?

November 4, 2021 · 10 min