Skip to content

Instantly share code, notes, and snippets.

@mhujer
Forked from VasekPurchart/.bashrc
Last active April 27, 2016 09:25
Show Gist options
  • Save mhujer/e836d5a21b07f95b956ecc22a6010a67 to your computer and use it in GitHub Desktop.
Save mhujer/e836d5a21b07f95b956ecc22a6010a67 to your computer and use it in GitHub Desktop.
GIT global configuration and enhancements
# used by Git (commit messages, rebase, ...)
export EDITOR=vim
# GIT bash current branch
# by HABR (modified by Dundee)
export PSORIG="$PS1"
function GITBRANCH() {
BRANCH="$(git branch 2>/dev/null | grep '*' | cut -d" " -f2-)"
if [ -n "$BRANCH" ] ; then
export PS1=$PSORIG$(echo -en "\[\033[01;33m\]$BRANCH > \[\033[00m\]")
else
export PS1="$PSORIG"
fi
}
PROMPT_COMMAND="GITBRANCH"
[user]
name = Vasek Purchart
email = me@vasekpurchart.cz
[core]
# windows->true, linux-> input
autocrlf = input
safecrlf = false
# must be absolute path
excludesfile = /home/Vasek/.gitignore_global
[alias]
# empty commit at the repo start - useful for rebasing
# see https://coderwall.com/p/m_pgbg/start-git-repos-with-an-empty-commit
start = !git init && git commit --allow-empty -m \"Initial commit\"
# safer force-push
# https://developer.atlassian.com/blog/2015/04/force-with-lease/
# http://stackoverflow.com/questions/30542491/push-force-with-lease-by-default
pushf = push --force-with-lease
f = fetch
# updates your branch with upstream (if fast-forward is possible)
ff = !git merge --ff-only `git rev-parse --symbolic-full-name --abbrev-ref=strict HEAD@{u}`
fp = fetch --prune
st = status
cm = commit
cma = commit --amend
br = branch
co = checkout
cp = cherry-pick
df = diff
rb = rebase
rbi = rebase -i
rbc = rebase --continue
rh = reset --hard
su = submodule update
# graph for current branch
l = log --graph --decorate --pretty=oneline --abbrev-commit
# graph for all branches
ll = log --graph --decorate --pretty=oneline --abbrev-commit --all
# log for current branch showing diffs (-m is for showing mergecommits too)
ld = log -p -m
# log for current branch showing summary of changed files (-m is for showing mergecommits too)
ls = log --stat -m
# number of commits for each person
stats = shortlog -n -s --no-merges
# remove remote branch (remote must be named origin), usage: git rmb test
rmb = !sh -c 'git push origin :$1' -
# shows local > tracked remote
brt = for-each-ref --format=\"%(refname:short) > %(upstream:short)\" refs/heads
# get upstream tracked branch or error
brtracked = rev-parse --symbolic-full-name --abbrev-ref=strict HEAD@{u}
# commit all changes to a WIP commit
wip = !git add --all && git commit -m WIP
[remote "origin"]
# git push -> push current HEAD into tracked remote branch
push = HEAD
[diff]
mnemonicprefix = true
[pull]
rebase = true
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
meta = yellow bold
frag = magenta bold
old = red bold
new = green bold
[color "status"]
added = green
changed = yellow
untracked = cyan
lockfile
*.log
######################
# OS generated files #
######################
.DS_Store
ehthumbs.db
Icon
Thumbs.db
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment