Git

.PHONY: git
git:
     test -L $(HOME)/.gitconfig || ln -s $(shell pwd)/gitconfig $(HOME)/.gitconfig

Author

Setting basic identity details for commits

[user]
name  = Alex Carney
email = alcarneyme@gmail.com

Aliases

[alias]
co = checkout
amend = commit --amend --no-edit  # Squash changes into the previous commit

A nice view of a repository’s history

hist = log --branches --remotes --tags --graph --oneline --decorate
$ git hist
* 9bbbedca (origin/sphinx-8, sphinx-8) lsp: Drop Sphinx 5.x, add support for Sphinx 8.x
*   44f758bc (HEAD -> develop, upstream/develop, origin/develop) Merge branch 'release' into develop
|\
| * 6a2086c7 (tag: esbonio-vscode-extension-v0.95.1, upstream/release, release) Esbonio VSCode Extension Release v0.95.1
| * 72be1341 (origin/take-2) code: Update changelog
* | fc194b26 Start testing against 3.13
* | 306fbaf9 Bump ruff version
* | 4552ff34 [pre-commit.ci] pre-commit autoupdate
* | 5bce0a3c build(deps): bump semver from 7.6.2 to 7.6.3 in /code
* | d02c69ad build(deps-dev): bump @vscode/vsce from 2.30.0 to 2.31.1 in /code
* | 8de0b24a devenv: Install the latest hatch
* | c96bc561 devenv: Bump NodeJS version
...

A better (for some definition of “better”) git status command

s = !git status -sb && git --no-pager diff --shortstat
$ git s
## release...origin/release [ahead 2]
 M dotfiles.rst
 M dotfiles/bash.rst
?? dotfiles/.#git.rst
?? dotfiles/git.rst
 2 files changed, 12 insertions(+), 3 deletions(-)

Credential Helper

This tells git to use the GitHub CLI to authenticate when pushing/pulling from GitHub

[credential "https://github.com"]
helper =
helper = !gh auth git-credential

Diffing

Using the histogram algorithm apparently produces nicer diffs when code is moved

[diff]
algorithm = histogram
colorMoved = default

Merging

The following option describes how git should render merge conflicts

[merge]
conflictstyle = diff3

Another option that might be worth experimenting with is zdiff3, see this article

Rebasing

I rebase all the time most of the time to squash a bunch of fixup! commits together. The following options remove the need to manually pass –autosquash and –autostash to the rebase command each time.

[rebase]
autosquash = true
autostash = true

Other Options

[commit]
verbose = true

[core]
editor = nvim

[pull]
rebase = true

[rerere]
enabled = true

# Used by forge.el
[github]
user = alcarney