May 23, 2025

How I Use: Git

My Git workflow and best practices for version control, including commit conventions, rebasing, and tools like tig and git-crypt.

I use Git to track versions of files. Here's how:

Summary

  • I create repositories with git init
  • I commit with git commit
  • I mostly follow semantic commit conventions when writing commit messages
  • I push with git push
  • I add remote origins with git remote add origin
  • If I'm pushing after adding the origin remote, I git push -u origin master

Git Configuration

I have a file ~/.gitconfig. I think it has been mostly auto-populated. Here are the settings I like it to contain:

[core]
	editor = nano
[merge]
	tool = kdiff3
  • I prefer nano for editing commit messages
  • I prefer kdiff3 for resolving merge conflicts

Commit Messages

I usually write commits like this:

prefix: headline

More details here

http://link.example/some/task/tracker

Some prefixes I use are:

  • feat: something new
  • fix: something fixed
  • test: something test-related
  • style: something formatted
  • chore: something related to CI or build pipeline

I don't use the refactor prefix.

Rebasing

If I fall behind an upstream remote, I git rebase master. This keeps my Git history clean.

If I try to push and see that I'm behind, I do the above.

If I'm developing a feature, I sometimes make commits like feat: WIP. I sometimes make multiple of these, causing my commit history to look like:

feat: WIP
feat: WIP
feat: WIP 2
feat: WIP

Before publishing my work or asking for review, I squash these commits into one and give them a nicer commit message. I use a command like git rebase -i HEAD~4 (where 4 is the amount of commits we want to change) and change the commits to s for squash. Then, I run git commit --amend to change the message.

TUI

I almost always use tig when I use Git. It's much faster for me than writing the commands. See How I Use: Tig for Git

Secrets

I use git-crypt for storing secrets in Git. See How I Use: Git Crypt for Git

Git Version Control Workflow Developer Tools

Let's Build Something Amazing

Ready to discuss your next project? I'm always interested in tackling complex challenges and building innovative solutions that drive business growth.