Recent Posts (Page 7)

Git: Undo a rebase with git reflog

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.

Read more...

Django-related Deals for Black Friday and Cyber Monday 2023

Here are some Django-related deals for this year’s Black Friday (24th Nov) and Cyber Monday (27th Nov), including my own.

Read more...

Django: Stop a backgrounded runserver with lsof

If you start runserver but your terminal session gets closed, the server can continue running in the background. For example, this can happen when your IDE crashes. This situation is annoying because you can’t stop the backgrounded runserver with Control+C.

Read more...

My appearance on The Python Show

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:

Read more...

My appearance on the PyBites Podcast

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:

Read more...

My appearance on The Real Python Podcast 179

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:

Read more...

Django: Maybe disable PostgreSQL’s JIT to speed up many-joined queries

Here’s a write-up of an optimization I made in my client Silvr’s project. I ended up disabling a PostgreSQL feature called the JIT (Just-In-Time) compiler which was taking a long time for little benefit.

Read more...

Git: Show commits that come after

git log with a commit SHA shows that commit and those before it:

Read more...

GitHub Actions: Faster Python runs with cached virtual environments

Most projects I work on use Python, good ol’ Pip, and pip-tools. Below is a pattern I’ve used to speed up the GitHub Actions workflow runs on several such projects. On larger projects with many dependencies, it can save tens of seconds per run.

Read more...

Git: Force push safely with --force-with-lease and --force-if-includes

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:

Read more...

Git: Show a commit message or subject

To show only the subject of the latest commit (the first line of its message), use:

Read more...

Shell commands to copy to clipboard

The clipboard is an easy way to transfer data from the command line to other tools. Use your system’s “copy to clipboard” command to store a command’s output for pasting into other applications.

Read more...

Git: Rebase an old branch incrementally

You worked on a sizeable feature branch some time ago but left it to focus on other things. Now you’re ready to pick it up, so you want to rebase it onto your updated main branch. But when you try that, you’re presented with an overwhelming number of merge conflicts.

Read more...

Boost Your DX bundle deal

I released Boost Your Git DX nearly two weeks ago. It’s the second in my “Boost Your DX” series, following last year’s Boost Your Django DX. Both books aim to improve your development experience with their respective tool.

Read more...

“Boost Your Git DX” out now

My new book, Boost Your Git DX is out now, on my birthday 🥳. It’s taken nearly a year of work with four months in early access.

Read more...

Git: Show the initial (root) commit

To show the initial, or root, commit* of your repository, use:

Read more...

My fourth appearance on Django Chat

I’ve once more had the pleasure of joining Carlton and Will on the Django Chat podcast, in Episode #146. We spoke on Tuesday, just hours after Django 5.0 alpha 1 was released, on several topics:

Read more...

Git: Don’t create .gitkeep files, use .gitignore instead

Git only tracks files, not directories. It will only create a directory if it contains a tracked file. But sometimes you need to “track” a directory, to ensure it exists for fresh clones of a repository. For example, you might need an output directory called build.

Read more...

Django: Move a template tag library into builtins

Django’s template engine has an underappreciated builtins option that selects libraries to preload in every template. Making a library a builtin avoids the need for an explicit {% load %} tag whenever you use its tags or filters. Putting key libraries in builtins can shorten your templates and make development a little bit faster.

Read more...

Introducing flake8-logging

The Python standard library’s logging module is a go-to for adding observability to applications. Many tools also integrated with it or enhance its capabilities, such as structlog and Sentry.

Read more...

Git: Clear unreachable files from the .git directory

Every object you commit in Git is copied into its object store, within the .git directory. If you undo a commit, the commit object and associated file objects remain in Git’s object store, at least for a while. The normal garbage collection process will clean them out, by default in 30 days.

Read more...

Docker: Clean up unused stuff on your development machine

Docker keeps all objects (images, containers, volumes, etc.), with no automatic cleanup. It thus consumes disk space without bound, which can eventually fill up your development machine.

Read more...

Git: Output the top-level directory of the current repository

To output the root directory of the current repository, use:

Read more...

Git: Output just the current branch name

To print just the name of the current branch, use:

Read more...

Django: The perils of string_if_invalid in templates

Django’s template engine has a string_if_invalid option that replaces missing variable lookups with a string of your choice:

Read more...