Skip to content

Instantly share code, notes, and snippets.

@jeangatto
Last active May 8, 2026 16:47
Show Gist options
  • Select an option

  • Save jeangatto/9ed0f02204f406586ad93d7ff9d98467 to your computer and use it in GitHub Desktop.

Select an option

Save jeangatto/9ed0f02204f406586ad93d7ff9d98467 to your computer and use it in GitHub Desktop.
Git Config (The Ultimate Guide, Best Configs)
# REF: https://geekworkbench.com/blog/technical/git-config-global-settings/
# REF: https://www.git-tower.com/blog/the-ultimate-guide-to-git-config
[user]
name = #your-name
email = #your-email
[core]
# Windows: convert LF to CRLF on checkout, CRLF to LF on commit
autocrlf = true
# Use Visual Studio Code as the default editor for Git
editor = code --wait
# Ignoring File Permissions
fileMode = false
# The Commit Graph: This feature dramatically speeds up history-traversing operations like git log.
commitGraph = true
# Filesystem Monitor (fsmonitor): This is perhaps the biggest performance booster for large repos.
# It uses a background process to watch for file changes, making commands like git status nearly instantaneous.
fsmonitor = true
# The Untracked Cache: Works with fsmonitor to speed up how Git finds new, untracked files.
untrackedCache = true
# Pager Configuration: This configuration sets up Git to use the 'less' pager with specific options.
# -F: Automatically exit if the content fits on one screen.
# -X: Don't clear the screen after exiting the pager.
# -R: Allow raw control characters (like color codes) to be displayed correctly.
pager = less -F -X -R
[fetch]
# When fetching from a remote repository, Git will automatically prune any remote-tracking branches that no longer exist on the remote.
# This helps keep your local repository clean and up to date with the remote.
prune = true
# When fetching from a remote repository, Git will automatically write the commit graph, ensuring that the commit graph is always up to date without requiring manual intervention.
writeCommitGraph = true
[init]
defaultBranch = main
[push]
# The simple mode pushes the current branch to the remote branch with the same name, but only if the upstream is configured.
# This is the safest default and prevents accidental pushes to wrong branches.
default = simple
# Git automatically configures the upstream branch during the first push, eliminating the need to manually use the -u or --set-upstream flag.
autoSetupRemote = true
[color]
ui = auto
branch = auto
diff = auto
status = auto
[merge]
# Use Visual Studio Code as the default merge tool for Git
tool = vscode
[mergetool "vscode"]
# The --wait flag tells Visual Studio Code to wait until the merge is resolved before returning control to Git.
# This allows you to focus on resolving the merge conflicts without worrying about timing issues.
cmd = code --wait $MERGED
[diff]
# Use Visual Studio Code as the default diff tool for Git
tool = vscode
# Better Diffs: You can tell Git to use a different algorithm for calculating diffs, which can sometimes produce more readable results.
# myers: The default algorithm (fast, but may produce confusing diffs).
# patience: Slower, but often more human-readable.
# minimal: Aims to generate the smallest possible diff.
# histogram: An improvement over patience (faster, with similar quality).
algorithm = histogram
[difftool "vscode"]
# The --diff flag tells Visual Studio Code to open in diff mode, showing the differences between the two files side by side.
# The --wait flag ensures that Git waits until you have finished reviewing the differences before proceeding.
cmd = code --wait --diff $LOCAL $REMOTE
[credential]
# Windows: use Credential Manager
helper = manager
[apply]
# When applying patches, ignore whitespace changes. This can help prevent conflicts caused by differences in line endings or indentation.
whitespace = fix
[rerere]
# Reuse Recorded Resolution: once enabled, Git will remember how you resolved a conflict. The next time it sees the exact same conflict, it will resolve it for you automatically!
enabled = true
[gc]
# Git will automatically write the commit graph during garbage collection, ensuring that the commit graph is always up to date without requiring manual intervention.
writeCommitGraph = true
[help]
# For the Typo-Prone Developer, Waits 1 second (10 deciseconds) before running the corrected command
autocorrect = 10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment