Skip to content

Instantly share code, notes, and snippets.

@sanathks
Last active May 7, 2022 21:54
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save sanathks/da1ccc6def41b072fb64 to your computer and use it in GitHub Desktop.
Save sanathks/da1ccc6def41b072fb64 to your computer and use it in GitHub Desktop.
function parse_git_dirty() {
git diff --quiet --ignore-submodules HEAD 2>/dev/null; [ $? -eq 1 ] && echo "*"
}
function parse_git_branch() {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/\1$(parse_git_dirty)/"
}
alias ga="git add ."
alias gaa="git add --all"
alias gc="git commit -m"
alias push='git push origin "$(parse_git_branch)"'
alias pull='git pull --rebase origin "$(parse_git_branch)"'
alias gs="git status"
alias checkout='git checkout'
alias gclr="git checkout ."
alias gbr="git branch | grep -v "master" | xargs git branch -D"
alias cm="git checkout master"
alias cb="git checkout -"
alias nb="git checkout -b"
alias c="git checkout"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment