Skip to content

Instantly share code, notes, and snippets.

@atheiman
Last active July 13, 2026 21:57
Show Gist options
  • Select an option

  • Save atheiman/f5aa05aec2dd4bea9d8382c7f9d5bb44 to your computer and use it in GitHub Desktop.

Select an option

Save atheiman/f5aa05aec2dd4bea9d8382c7f9d5bb44 to your computer and use it in GitHub Desktop.
gitconfig showing some common options I use
[user]
name = John Doe
email = john.doe@example.com
username = jdoe01
[alias]
co = checkout
br = branch
st = status
# Show cloned repo local path. `cd $(git root)` is useful from inside large projects.
root = !pwd
# Show origin default branch.
default-branch = !git symbolic-ref refs/remotes/origin/HEAD | cut -f4 -d/
# Checkout the default branch and pull the latest from `origin`. Useful after youre done with a
# feature branch to reset on the default branch.
pull-default-branch = !git co $(git default-branch) && git pull origin $(git default-branch)
# Attempt to delete every branch except (`grep -v`) the current branch and the default branch
prune-branches = "!git_default_br=$(git default-branch) && \
for br in $(git br | grep -v -e '^\\*' -e \"^\\s*${git_default_br}$\"); do \
git br -d \"$br\" 2>/dev/null || true; \
done && \
echo \"Remaining branches:\" && \
git br"
[init]
defaultBranch = main
[http "https://git.example.com]
# Example configuring git to connect to internal git server with internally signed certificate.
# Get cert body with `openssl s_client -connect git.example.com:443 -showcerts < /dev/null`
sslCAInfo = C:/Users/jdoe01/example-com-internal-ca-cert.pem
# Include other gitconfig based on cloned repo local path. I use this to set corporate email addresses, etc
[includeIf "gitdir:~/code/git.example.corp/"]
path = ~/.gitconfig-example-corp
[includeIf "gitdir:~/code/gist.github.com/"]
path = ~/.gitconfig-github
[includeIf "gitdir:~/code/github.com/"]
path = ~/.gitconfig-github
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment