Skip to content

Instantly share code, notes, and snippets.

@imjma
Created July 29, 2015 00:51
Show Gist options
  • Save imjma/4f3f193c625f54a4d042 to your computer and use it in GitHub Desktop.
Save imjma/4f3f193c625f54a4d042 to your computer and use it in GitHub Desktop.
for ubuntu
__git_complete_file=/usr/share/bash-completion/completions/git
if [ -f __git_complete_file ]; then
source __git_complete_file
fi
unset __git_complete_file
alias g='git'
alias gb='git branch'
alias gba='git branch -a'
alias gc='git commit -v'
alias gcmsg='git commit -m'
alias gco='git checkout'
alias gcm='git checkout master'
alias gcd='git checkout develop'
alias gl='git pull'
alias gp='git push'
alias ga='git add'
alias gau='git add -u'
alias gss='git status -s'
alias gst='git status'
alias gm='git merge'
alias grh='git reset HEAD'
alias grhh='git reset HEAD --hard'
#
# Will return the current branch name
# Usage example: git pull origin $(current_branch)
#
function current_branch() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
ref=$(git rev-parse --short HEAD 2> /dev/null) || return
echo ${ref#refs/heads/}
}
function current_repository() {
ref=$(git symbolic-ref HEAD 2> /dev/null) || \
ref=$(git rev-parse --short HEAD 2> /dev/null) || return
echo $(git remote -v | cut -d':' -f 2)
}
alias ggpull='git pull origin $(current_branch)'
alias ggpush='git push origin $(current_branch)'
# Git Aliases AutoComplete
type __git_complete >/dev/null 2>&1 && {
__git_complete g _git
__git_complete gb _git_branch
__git_complete gba _git_branch
__git_complete gc _git_commit
__git_complete gbmsg _git_commit
__git_complete gco _git_checkout
__git_complete gl _git_pull
__git_complete gp _git_gpush
__git_complete ga _git_add
__git_complete gau _git_add
__git_complete gss _git_status
__git_complete gst _git_status
__git_complete gm _git_merge
__git_complete grh _git_reset
__git_complete grhh _git_reset
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment