Skip to content

Instantly share code, notes, and snippets.

@sixertoy
Last active April 12, 2016 15:27
Show Gist options
  • Save sixertoy/ec5ee08dcca0a37bea02c14af08c30f1 to your computer and use it in GitHub Desktop.
Save sixertoy/ec5ee08dcca0a37bea02c14af08c30f1 to your computer and use it in GitHub Desktop.

GIT Aliases

~/.bash_profile

Show current GIT branch name

function git-name {
  git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}

Show current GIT branch description

function git-desc {
  branch=$(git rev-parse --abbrev-ref HEAD)
  desc=$(git config branch.$branch.description)
  echo -e "$desc"
}

Show all GIT branches name with description

function git-br {
  branches=$(git for-each-ref --format='%(refname)' refs/heads/ | sed 's|refs/heads/||')
  for branch in $branches; do
    desc=$(git config branch.$branch.description)
    if [ $branch == $(git rev-parse --abbrev-ref HEAD) ]; then
      branch="* \033[0;32m$branch\033[0m"
     else
       branch="  $branch"
     fi
     echo -e "$branch \033[0;36m$desc\033[0m"
  done
}

Show current GIT branch name in console

export PS1="\[\033[01;36m\]\u@\h:\[\033[01;34m\]\$(git-name) \[\033[01;32m\]\w \[\033[01;34m\]\n$ \[\e[0m\]"

~/.gitconfig

mg = merge
br = branch
ci = commit
st = status
rb = rebase
co = checkout
llog = log -1
cr = cherry-pick
ca = !git add -A . && git commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment