devl.cz/ git

GIT

Config

Global configuration goes to ~/.gitconfig. This can be edited by git commands or by hand.

Following commands will set up basic user info:

git config --global user.name "John Doe"
git config --global user.email "john.doe@example.com"

In config, it looks like this:

[user]
name = John Doe
email = john.doe@example.com

Let’s fill the rest directly.

Essentials:

[alias]
# Too long to type...
ci = commit
co = checkout
cp = cherry-pick
ds = diff --name-status
st = status
su = submodule update --init --recursive
id = rev-parse HEAD
info = remote show origin
tree = log --graph --stat

# List branches. This alias is safer than using `branch` directly,
# it won't create a new (weirdly named) branch if you mistype the args.
branches = branch -vv
bl = branch -vv

# Remove all merged branches
bc = !git branch -q --merged | grep -v '^[*+]' | grep -v '\\bmaster\\b' | xargs git branch -d

[fetch]
# Prune after fetch/pull (git remote prune origin)
# Set this if you don't like zombie remotes.
prune = true

Tools:

[core]
editor = mcedit