A part of the dotfiles collection
This git configuration uses a few external pieces of software which you many need to install.
- Difftastic via: brew install difftastic
- Ansible via: brew install ansible
- GitHub CLI via: brew install gh
[alias]
# Git aliases: Shortcuts for commonly used Git commands
# Alias to list all defined aliases in the current configuration
aliases = ! git config --list | awk '/alias/{ print $1 }' | perl -pe 's/alias\\.//g' | perl -pe 's/=.+//g'
# Alias to get the current branch name or a placeholder if not in a branch
branch-name = ! "git rev-parse HEAD >/dev/null 2>&1 && git rev-parse --abbrev-ref HEAD || echo '???no-branch???'"
# Alias to copy the latest commit's short ID to the clipboard (macOS only)
copy-latest-commit-id = ! git rev-parse --short HEAD | pbcopy
# Alias to add all files to previous commit, and then force push
ergh = ! git add . && git sneak && git push -f
# Alias to list the 10 most recent branches by committer date
recent = for-each-ref --count=10 --sort=-committerdate refs/heads/ --format="%(refname:short)"
# Alias to display commits made by you (jake.champion@netlify.com) in a concise format
recap = log --all --oneline --no-merges --author=jake.champion@netlify.com
# Alias to show both the repository name and current branch name
repo-and-branch-name = ! "echo $(git repo-name)':'$(git branch-name)"
# Alias to fetch the repository name from the remote, or fall back to the current directory name
repo-name = ! "[ -n \"$(git remote)\" ] && git remote -v | head -1 | cut -d ' ' -f 1 | grep -E --only-matching '([^:/ ]+/[^/ ]+)(\\.git)?$' | sed 's/\\.git$//' || basename $(pwd)"
# Alias to amend the last commit without changing its message (for minor tweaks or corrections)
sneak = commit --amend --no-edit
[branch]
# Sort branches by the committer date in descending order (most recent first)
sort = -committerdate
[column]
# Set Git to automatically adjust the UI (e.g., column formatting) based on the terminal size
ui = auto
[commit]
# Show verbose output for commits, including diff of changes
verbose = true
[core]
# Ignore global .gitignore file, specifying the user's personal Git ignore file
excludesfile = ~/.gitignore
# Set the pager for diff output to a tool with syntax highlighting (Git Delta)
# Install Delta via: brew install git-delta
pager = LESS='FR --redraw-on-quit' delta
[diff]
# Customize the diff behavior to use the histogram algorithm (better for large changes)
algorithm = histogram
# Settings for color and formatting of moved lines or whitespace changes
colorMoved = plain
colorMovedWS = allow-indentation-change
# Show 10 lines of context for diffs
context = 10
# Prefix diff lines with mnemonic symbols to make it more readable
mnemonicPrefix = true
# Track renamed files in diffs
renames = true
# Use a different tool (Difftastic) for diffs, which compares files based on syntax rather than line-by-line
# Install Difftastic via: brew install difftastic
tool = difftastic
[diff "ansible-vault"]
# For files encrypted with Ansible Vault, use ansible-vault to decrypt them for viewing the diff
# Install Ansible via: brew install ansible
textconv = ansible-vault view
[fetch]
# Automatically prune remote-tracking branches that no longer exist on the remote
prune = true
# Prune tags that no longer exist on the remote
pruneTags = true
# Fetch all remotes
all = true
[gpg]
# Use SSH format for GPG signatures
format = ssh
[help]
# Enable autocorrection for typos in Git commands (it will prompt with a suggestion)
autocorrect = prompt
[init]
# Create a 'main' branch by default instead of the older 'master' branch when initializing a new repository
defaultBranch = main
[interactive]
# Use Git Delta as the diff viewer when interacting with Git's interactive rebase
diffFilter = delta
[merge]
# Configure Git to use 'zdiff3' for showing conflicts (a 3-way diff tool with a more readable UI)
conflictstyle = zdiff3
[push]
# Automatically set up tracking for branches when you first push them
autoSetupRemote = true
# Push the current local branch to a remote branch with the same name
default = current
# Automatically push tags along with commits
followTags = true
[rebase]
# Automatically squash commits during rebase (combine multiple commits into one)
autosquash = true
# Automatically stash changes before a rebase and apply them afterward
autostash = true
# Update refs during rebase (ensure the reference to the branch is updated)
updateRefs = true
[rerere]
# Enable rerere ("reuse resolved resolution") to automatically remember how you resolved merge conflicts
# Git will attempt to resolve conflicts the same way you did in previous conflicts
enabled = true
# Automatically update the rerere cache when conflicts are resolved
autoupdate = true
[status]
# Display a summary of submodules when showing the status of the repository
submoduleSummary = true
[submodule]
# Automatically recurse into submodules when performing Git commands like pull, push, etc.
recurse = true
[tag]
# Sort tags by their version number, not lexicographically
sort = version:refname
[url "git@github.com:"]
# Replace 'https://github.com/' with 'git@github.com:' when performing operations on GitHub
insteadOf = https://github.com/
[credential "https://github.com"]
# Use GitHub's CLI credential helper to manage authentication when interacting with GitHub
helper =
helper = !/opt/homebrew/bin/gh auth git-credential
[credential "https://gist.github.com"]
# Use GitHub's CLI credential helper for authentication on GitHub Gists
helper =
helper = !/opt/homebrew/bin/gh auth git-credential
[url "https://github.com/"]
# Replace 'git@github.com:' with 'https://github.com/' when performing operations on GitHub
insteadOf = git@github.com:
[url "https://"]
# Replace 'git://' with 'https://' for safer HTTP connections
insteadOf = git://