Skip to content

Instantly share code, notes, and snippets.

@scarabaeus
Last active February 25, 2026 19:49
Show Gist options
  • Select an option

  • Save scarabaeus/3b4a618283dfa06e3e88de6d30883c61 to your computer and use it in GitHub Desktop.

Select an option

Save scarabaeus/3b4a618283dfa06e3e88de6d30883c61 to your computer and use it in GitHub Desktop.
Personal Git Configs

Setting up P4Merge as the default difftool for Git

  1. Download P4Merge for your operating system: https://www.perforce.com/downloads/visual-merge-tool
  2. Run the .dmg file that you just downloaded.
  3. Copy only the P4Merge app to your /Applications folder. (Unless you want the other apps as well.)
  4. Run the following lines in terminal:
git config --global diff.tool p4merge
git config --global difftool.p4merge.path /Applications/p4merge.app/Contents/MacOS/p4merge
git config --global difftool.prompt false

Debugging:

macOS

  • If you receive the error message: qt.qpa.fonts: Populating font family aliases took N ms. Replace uses of missing font family "Courier" with one that exists to avoid this cost. run git difftool and in P4Merge > Preferences... > Text Format > Font replace "Courier" with "Consolas".

Prettier Git Aliases for portability

git config --global alias.pretty-changed '!f(){ files=$(git diff --name-only --diff-filter=ACMRT origin/main...HEAD | grep -E "\.(ts|tsx|js|jsx|json|prisma|ya?ml)$" || true); if [ -n "$files" ]; then echo "$files" | xargs yarn prettier --write; else echo "No prettier-eligible changed files."; fi; }; f'
git config --global alias.pretty-staged '!f(){ files=$(git diff --cached --name-only --diff-filter=ACMRT | grep -E "\.(ts|tsx|js|jsx|json|prisma|ya?ml)$" || true); if [ -n "$files" ]; then echo "$files" | xargs yarn prettier --write; else echo "No prettier-eligible staged files."; fi; }; f'

Command line usage

git pretty-changed
git pretty-staged

Lint Git Aliases for portability

git config --global alias.lint-changed '!f(){ \
  files=$(git diff --name-only --diff-filter=ACMRT origin/main...HEAD \
    | grep -E "\.(ts|tsx|js|jsx)$" || true); \
  if [ -n "$files" ]; then \
    echo "$files" | xargs yarn -s eslint; \
  else \
    echo "No eslint-eligible changed files."; \
  fi; \
}; f'

Command line usage

git lint-changed
@scarabaeus
Copy link
Author

FYI: I don't like using P4Merge as the merge tool, just as the diff tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment