63 Posts Tagged ‘git’

(All tags.)


GitHub: top commands in gh, the official GitHub CLI

gh (pronounced… “guh”?) is GitHub’s official command line interface (CLI) tool. It lets you interact with GitHub directly from the command line, supporting most key features across more than 25 commands and over 200 subcommands. It’s also great for bridging the terminal-browser gap, allowing you to jump to pages relevant to your current context, such as the PR for the current branch.

Read more...

“Boost Your GitHub DX” out now

My new book, Boost Your GitHub DX is out now!

Read more...

Git: check if a commit exists on a given branch

To check if a commit SHA exists on a given branch, you have a couple of options.

Read more...

Git: count files in a repository

When you want to count the number of files within a Git repository, it's generally best to use Git itself for the task because it will skip over any generated or downloaded files. Here is a command chain to use to count all committed files within the current directory:

Read more...

Git: find the largest commits

Recently, I was working in a new repository and found the git blame output often pointed back to a large repository-wide formatting commit (applying Black to all Python files). To ignore this commit in git blame, I added its SHA to a .git-blame-ignore-revs file, per this documentation:

Read more...

Git: share a full repository as a file with git fast-export

Typically, we share repositories through a Git host, like GitHub, allowing others to clone the repository to get a copy. But sometimes that’s not an option, for example when trying to get someone started on your project when corporate onboarding processes take days to grant GitHub access.

Read more...

Git: list checked-in symlinks

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?

Read more...

Git: fix a filename case collision

You may encounter this warning when cloning a Git repository:

Read more...

Boost Your Git DX now has a free sample

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.

Read more...

Boost Your Git DX second update out now

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!

Read more...

Shell: benchmark the difference between two Git branches with hyperfine

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.

Read more...

Git: force colourization with color.ui or --color

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.

Read more...

Git: undo a pull

Okay, so you just ran git pull on a branch, and something broke, so you want to undo it. Here are two ways how.

Read more...

Git: count commits with rev-list

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:

Read more...

Git: find when a commit was reverted or reapplied

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:

Read more...

Git: generate statistics with shortlog

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.

Read more...

Git: avoid reset --hard, use reset --keep instead

When I started learning Git, I found many references covering two ways to undo commits with git reset:

Read more...

Django: Pinpoint upstream changes with Git

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.

Read more...

Git: Show the first tag containing a commit SHA

Say you have a commit SHA and want to know the first version it was released in. You can use this command:

Read more...

Boost Your Git DX update out now

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.

Read more...

Git: the basics of git bisect

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.

Read more...

Git: Improve diff generation with diff.algorithm=histogram

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.

Read more...

Boost Your DX bundle deal update

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.

Read more...

Git: Improve conflict display with the zdiff3 style

By default, Git presents merge conflicts like so:

Read more...

Git: Enable denser git status output with --short or status.short

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:

Read more...