Set Up Git Aliases and Global .gitignore for Faster WordPress Development

Typing full Git commands many times a day is a hidden source of developer friction that aliases can eliminate entirely — a two-letter alias like gs for git status adds up to thousands of saved keystrokes each month. Git aliases defined under [alias] in ~/.gitconfig are available in every repository on the machine without any per-project setup. Shell aliases prefixed with ! in the alias value allow you to combine multiple Git commands or pipe output through Unix tools in a single alias call. A global ~/.gitignore_global file prevents OS and editor artefacts from appearing in every project’s status output and eliminates the need to add them to per-project .gitignore files. Common entries include macOS .DS_Store files, JetBrains .idea/ directories, VS Code .vscode/ settings, and Node.js node_modules/. The core.excludesFile config key tells Git the path to the global ignore file and can be set to any absolute path you prefer. Configuring core.autocrlf=input on macOS and Linux prevents Windows line-ending contamination from files committed by cross-platform team members. Setting push.default=current makes git push push the current branch to its same-named remote counterpart without requiring an explicit upstream link. The diff.colorMoved=zebra option colours moved code blocks differently from added or removed lines, making refactoring diffs far easier to read at a glance. You can inspect the full merged configuration at any time with git config --list --show-origin, which prints each setting alongside the file that defines it. The Git branching strategies post pairs naturally with these aliases — a gco alias for git checkout makes switching between feature and hotfix branches much faster. For WordPress teams, adding wp-config.php, .env, and wp-content/uploads/ to the global ignore file prevents accidental commits of credentials or binary media assets to the repository. A git log --oneline --graph --decorate alias is one of the most useful productivity boosts for visualising branch topology in busy repositories.

Problem: Typing full Git commands repeatedly and maintaining per-project .gitignore entries for OS and editor files wastes time and clutters project repositories.

Solution: Define short aliases under [alias] in ~/.gitconfig and set core.excludesFile to a global ~/.gitignore_global that covers OS, editor, and WordPress-specific patterns.

# ~/.gitconfig
[alias]
    s   = status
    co  = checkout
    br  = branch
    ci  = commit
    lg  = log --oneline --graph --decorate --all
    undo = reset --soft HEAD~1
    unstage = restore --staged

[core]
    excludesFile = ~/.gitignore_global
    autocrlf     = input

[push]
    default = current

[diff]
    colorMoved = zebra

# ~/.gitignore_global
.DS_Store
Thumbs.db
.idea/
.vscode/
*.swp
*.swo
node_modules/
vendor/
wp-config.php
.env
wp-content/uploads/
wp-content/cache/

NOTE: Apply the global config with git config --global core.excludesFile ~/.gitignore_global and verify with git config --global --list | grep excludes — entries in the global ignore file are never staged, so you will not see them in git status output.