Skip to content

Instantly share code, notes, and snippets.

@nepsilon
Last active October 19, 2020 19:15
Show Gist options
  • Star 28 You must be signed in to star a gist
  • Fork 9 You must be signed in to fork a gist
  • Save nepsilon/15811b7a3c430ec9dedf2a14cc1a86b2 to your computer and use it in GitHub Desktop.
Save nepsilon/15811b7a3c430ec9dedf2a14cc1a86b2 to your computer and use it in GitHub Desktop.
A better setup for Git — First published in fullweb.io issue #46

A better setup for Git

Git default configuration is good but it can be personalized to improve your workflow efficiency. Here are some good lines to put in your ~/.gitconfig:

# The basics, who you commit as:
[user]
  name = John Doe
  email = john@doe.org
# Your Github username
[github]
  user = githubusername
# Some aliases to save 1000s keystrokes each year:
[alias]
  log = log --color
  co = checkout
  br = branch
  ci = commit
  st = status
  # Long but worth it, gives you output like: 
  # * 4be77ea  Add issue 42. 4 weeks ago by Julien
  lg = log --graph --pretty=format:'%Cred%h%Creset %C(yellow)%d%Creset %s %Cgreen%ar%Creset by %C(yellow)%an%Creset' --abbrev-commit
  # Convenient to see diff in minified files
  dw = diff --color-words
# Add colors
[color]
  ui = true
  diff = auto
# Avoid messy merge commits with autorebase
[branch]
  autosetuprebase = always
# Push the current branch by default
[push]
  default = current
# Guess what you really meant
[help]
  autocorrect = 1
# Tell git you have a global .gitignore
[core]
  excludesfile = ~/.gitignore
# Remove usage hints
[advice]
  statusHints = false
# Tell where are the diff from,
# instead of using a and b notation
[diff]
  mnemonicprefix = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment