git-cliff is a tool for generating change logs from commit history Difftastic

Ergonomics

  • Forgit is a zsh and fzf enabled command line tool that allows for more interactive git command use.
  • tig is a text-mode interface for git.
  • lazygit is a terminal UI for git

Commit Messages

Git Hacks

Rebuilding modified time in a cloned git repo hacks

When cloning a git repo, it will not retain the file metadata of the files within the repo (created/accessed/modified) time will all roughly be set to clone time. If you have tooling that depends on modification time of the files you can reconstruct the modification time based on the commit time of the commit that last modified the file. There is a tool/package called git-tools which includes a python tool called git-restore-mtime. Once installed this can be called within a git repo like:

git restore-mtime

Add git repo on server hacks

root@git:/home/git/private # mkdir blog.git
root@git:/home/git/private # cd blog
root@git:/home/git/private/blog # git init --bare --shared
Initialized empty shared Git repository in /home/git/private/blog/
root@git:/home/git/private/blog # cd ..
root@git:/home/git/private # chown -R git:git blog.git

Change git identity based on repo hacks

To set a specific git identity and config based on the repo you are in you can use the includeIf directive in your .gitconfig. For example1:

[includeIf "hasconfig:remote.*.url:git@github.com:orgname/**"]
  path = ~/.config/git/config-gh-org

git-filter-repo for Rewriting Git History hacks

git-filter-repo is a standalone Python script that can be used to rewrite the history of a Git repository, similar to the BFG Repo-Cleaner tool. It provides a powerful set of filters that can be used to modify the repository history in various ways, such as changing the author name/email, rewriting commit messages, removing sensitive data, and more. Unlike the BFG Repo-Cleaner, git-filter-repo is actively maintained and recommended by the Git project. It’s designed to be more efficient and flexible than the BFG Repo-Cleaner, and can handle larger repositories more easily. To use git-filter-repo, you can clone the repository and run the git-filter-repo script with the desired filters and options. The script will rewrite the history of the repository based on the specified filters, and create a new repository with the modified history.

Repo can be found here: https://github.com/newren/git-filter-repo

A useful example of using it like a library to build more complex usages can be found here.

1. Mora, B. E. How I configure my Git identities. https://benji.dog/articles/git-config/ (2024).