Adam Johnson (original) (raw)
Git: list checked-in symlinks
2025-05-19
Git supports storing symbolic links (symlinks) in your repository, which are filesystem links that point to another file or directory. These are great for when you want to have the same file at multiple locations in your repository, such as some configuration file that is used for multiple sub-projects. But how can you list all the symlinks in your repository?
Git: fix a filename case collision
2025-05-05
You may encounter this warning when cloning a Git repository:
Boost Your Git DX now has a free sample
2025-02-03
Last week, I released the second update to my book Boost Your Git DX. Today I’m happy to announce that I have released a free sample of the book.
Boost Your Git DX second update out now
2025-01-28
Today I have released the second update to Boost Your Git DX, my book of developer experience (DX) recommendations for using Git. Since the last update (2024-04-04), it has grown again by 28 pages, for a new total of 391 pages!
Shell: benchmark the difference between two Git branches with hyperfine
2025-01-14
hyperfine is a neat tool for benchmarking commands. If you provide it multiple commands, its output includes a comparison, saying which is the fastest, and by how much.
Git: force colourization with color.ui or --color
2025-01-03
By default, Git only colourizes in its output when writing to an interactive terminal. Sometimes, this heuristic isn’t accurate, for example, when you’re piping Git output through another command. In such cases, you can force colourization on or off with either the color.ui
configuration option or the --color
option. Let’s look at both in turn.
Git: undo a pull
2024-12-31
Okay, so you just ran git pull
on a branch, and something broke, so you want to undo it. Here are two ways how.
Git: count commits with rev-list
2024-11-20
git rev-list lists details about commits (also known as “revisions”, hence the name). Its --count
option outputs the count of commits in the given range. Pass it @
, the short alias for HEAD
, to count commits on the current branch:
Git: find when a commit was reverted or reapplied
2024-09-18
Git doesn’t store reversion links between commits. It only relies on commit messages to track this information. When you run git revert
, the default message includes a line about the reverted commit:
Git: generate statistics with shortlog
2024-09-03
git shortlog generate statistics about the commits in a repository, intended to help generate project release notes. By default, it groups commits by author, but it can use other fields too. Use it for a more powerful dissection of a repository than tools like GitHub’s Insights tab.
Git: avoid reset --hard, use reset --keep instead
2024-09-02
When I started learning Git, I found many references covering two ways to undo commits with git reset
:
Django: Pinpoint upstream changes with Git
2024-04-24
Django’s release notes are extensive and describe nearly all changes. Still, when upgrading between Django versions, you may encounter behaviour changes that are hard to relate to any particular release note.
Git: Show the first tag containing a commit SHA
2024-04-22
Say you have a commit SHA and want to know the first version it was released in. You can use this command:
Boost Your Git DX update out now
2024-04-04
I have just released an update to my book Boost Your Git DX, six months after its initial release. This update adds some extra content and has a bunch of edits based on reader feedback. The PDF is now ten pages longer, for a total of 363.
Git: the basics of git bisect
2024-01-29
git bisect efficiently searches for a commit responsible for changing a given behaviour. git log
lets you see when a given file or line changed, but that’s often insufficient when the cause of some change is unclear. In such cases, git bisect
shines, as it lets you check your running system.
Git: Improve diff generation with diff.algorithm=histogram
2024-01-18
Contrary to common belief, Git doesn’t store diffs. It actually stores snapshots of whole files, heavily compressed to reduce redundancy. Then when displaying a diff is required, git diff
generates it on the fly.
Boost Your DX bundle deal update
2023-12-29
My two “Boost Your DX” books are available in a bundle deal, saving $10 compared to buying them separately. Great for improving your Django and Git skills at the same time.
Git: Improve conflict display with the zdiff3 style
2023-12-29
By default, Git presents merge conflicts like so:
Git: Enable denser git status output with --short or status.short
2023-12-07
By default git status
uses “long format”, which lists information explicitly. This format takes quite a lot of words and vertical space to split file status by section:
Git: Undo a rebase with git reflog
2023-11-24
If you make a mistake whilst rebasing, it might seem hard to undo. But with git reflog, you can find the original commit SHA and revert back to it. Let’s see how with an example.
My appearance on The Python Show
2023-11-17
Earlier this week, I made another podcast appearance on The Python Show, episode 22: Git and Django with Adam Johnson. As fellow authors, Mike and I talked a lot about the writing process, on topics like:
My appearance on the PyBites Podcast
2023-11-13
Last week, I made another podcast appearance on the PyBites Podcast, episode 139: Maximizing Your Developer Experience (DX) with Adam Johnson. We talked about various topics, including:
My appearance on The Real Python Podcast 179
2023-11-09
I had the pleasure of returning to The Real Python podcast in last week’s episode 179, Improving Your Git Developer Experience in Python. It was great to catch up with host Christopher Bailey and chat about:
Git: Show commits that come after
2023-11-02
git log
with a commit SHA shows that commit and those before it:
Git: Force push safely with --force-with-lease and --force-if-includes
2023-10-31
When you push, Git checks that you are only adding commits to the remote branch. If you try to push an out-of-date branch, it will fail: