I’ve been using git for various projects and want to share tips for making it more convenient.
One of git’s advantages is cheap branches. A branch is just a file in .git/refs/heads containing the id of the last commit, so creating a new branch takes very little time. With such capabilities, most programmers use branches extensively.
Whatever model you choose for branches, you can eventually forget which branch you’re on and commit code to the wrong place. Although this is easily fixed, you can avoid it by adding branch information to your bash prompt.
Installing git bash completion
Git includes several useful scripts, including git-completion.bash. After loading it, bash completion will include git commands, local and remote branch names, tags, and more. The script also defines useful functions for getting environment information.
% git
add -- add file contents to index
am -- apply patches from a mailbox
apply -- apply patch to files and/or to index
archimport -- import an Arch repository into git
archive -- create archive of files from named tree
bisect -- find, by binary search, change that introduced a bug
blame -- show what revision and author last modified each line of a file
br -- alias for 'branch'
branch -- list, create, or delete branches
bundle -- move objects and refs by archive
cat-file -- provide content or type information for repository objects
check-attr -- display gitattributes information
check-ref-format -- ensure that a reference name is well formed
checkout -- checkout branch or paths to working tree
checkout-index -- copy files from index to working directory
cherry -- find commits not merged upstream
</pre>
If you use MacPorts, ensure git-core is installed with the +bash_completion variant:
% sudo port install git-core +bash_completion
---> Computing dependencies for git-core
---> Cleaning git-core
If you installed git from source, search for the script:
**Update:** Enclose colors in PS1 with [], otherwise bash will incorrectly calculate prompt length and handle line wrapping incorrectly.
After setup, if the current directory is under git control, the command line will display the current branch name.
I’ve been using Claude Code lately to work on personal projects: a CLI for searching mountain peaks, Claude Code skills for route research, a Chrome extension for Mountaineers.org, and a tool to export GPX files from Strava. When Anthropic released Claude skills, I dove in and started experimenting with Obra’s superpowers. I liked that experience so much that I started building my own skills. This is one of them.
At the 2011 Pycon.UA conference, I presented on speeding up development with virtualized dev environments using VagrantUp and Fabric.
Virtualization lets developers create consistent, reproducible development environments across teams. Vagrant makes this process simple by providing a unified workflow for managing virtual machines, while Fabric automates deployment tasks.
I often need project version information for documentation, About boxes, or website footers. Instead of hardcoding version numbers, I let git provide them automatically.
For my projects, git describe works best. It doesn’t modify sources on checkout and provides version information in a format usable in other git commands such as git diff.
The limited console settings in Windows annoy many users. In particular, the font selection is limited to Consolas, Lucida Console, and vague “Raster Fonts.” This post explains how to add support for additional fonts.
Many fonts are more suitable for programming and administration tasks. You can find a good list in this article or here. I prefer Inconsolata.
You can connect your favorite font to the console, though it requires some registry work. Thanks to Scott Hanselman for the tips.
Comments