My favorite git aliases

submited by
Style Pass
2021-09-10 12:30:04

If you don’t want to type the entire text of each of the Git commands, you can easily set up an alias for each command using git config.

Most examples are pretty trivial, e.g. being able to type git co instead of git commit. I have autocomplete setup for my shell, so this breed of “type fewer characters” alias doesn’t give me much value.

I rarely get things perfect the first time. I’ll often make a commit (with a good commit message), and then realize I made some mistake: forgot to save a file in my editor, forgot to remove some debugging code, spelling error, etc.

This alias gives me a quick way to fix that, without adding any noisy commits that would make life harder for code reviewers or git bisect.

Often I’ll have a few small commits bundled together for one pull request. I already have good commit messages, and can aggregate those together to make a good pull request description.

This uses git log pretty formats to get a markdown listing of my pending commits. The crazy --format string handles indentation and line wrapping to keep the markdown valid.

Leave a Comment