Skip to content

Instantly share code, notes, and snippets.

@kujiy
Forked from numeraltwo/git_aliases
Last active May 3, 2017 14:11
Show Gist options
  • Save kujiy/c6afe3a8577e37af6566e1699bfc6f51 to your computer and use it in GitHub Desktop.
Save kujiy/c6afe3a8577e37af6566e1699bfc6f51 to your computer and use it in GitHub Desktop.
useful git and git-flow aliases
# GIT / GIT FLOW ALIASES
# https://gist.github.com/kujiy/c6afe3a8577e37af6566e1699bfc6f51
# alias gs="git status" # Unfortunately Ghost Script used `gs` already.
alias gss="git status"
alias gd="git diff"
alias gdc="git diff --cached"
gdn() { git diff --no-index -- $1 $2; }
alias gb="git branch"
alias gbr="git branch -r"
alias gst="git stash"
alias gsta="git stash apply"
alias gstl="git stash list"
alias gstc="git stash clear"
gl() { [[ $1 = "" ]] && git log -5 || git log -$1 ; }
glo() { [[ $1 = "" ]] && git log -5 --oneline || git log -$1 --oneline ; }
alias gft="git fetch --tags"
alias gfp="git fetch --prune"
alias gpt="git push --tags"
alias gpu="git push"
alias gp="git pull"
alias gaa="git add -A"
alias gau="git add -u"
ga() { git add $@; }
gc() { git commit -m "$@"; }
alias gca="git commit --amend"
alias gcm="git checkout master"
alias gmm="git merge master"
alias gcd="git checkout develop"
alias gmd="git merge develop"
gcf() { git checkout feature/$1; }
gffs() { git flow feature start $1; }
gfff() { git flow feature finish -F $(git_flow_current_branch); }
# Pick up the first "one" feature
gcfo() { git checkout $(git branch | grep feature | tail -1); }
gffo() { git flow feature finish -F $(git branch | grep feature | tail -1 | sed s/feature\/// | sed s/*//); }
gch() { git checkout hotfix/$1; }
gfhs() { git flow hotfix start $1; }
gfhf() { git fetch --tags; git pull origin master; git flow hotfix finish -F $(git_flow_current_branch); }
gcr() { git checkout release/$1; }
gfrs() { git flow release start $1; }
gfrf() { git flow release finish -F $(git_flow_current_branch); }
git_flow_current_branch(){ git rev-parse --abbrev-ref HEAD | cut -d/ -f 2; }
glt() {
LAST_TAG=$(git for-each-ref --format="%(refname:short)" --sort=taggerdate refs/tags | tail -1 | git for-each-ref --format="%(refname:short)" --sort=taggerdate refs/tags | tail -1);
echo $LAST_TAG | xargs echo -n | pbcopy;
echo "LAST TAG: "$LAST_TAG;
}
gut (){
git tag -d $1;
git push --progress origin :refs/tags/$1;
}
gbd (){
git branch -D $1;
}
gpo (){
git push origin $1;
}
gpod (){
git push origin :$1;
}
alias gitrevert="git checkout -- $1"
alias gc--="git checkout -- $1"
# GIT / GIT FLOW ALIASES <-
@kujiy
Copy link
Author

kujiy commented Apr 15, 2016

Changed git stash gs to gst and instead, add git status as gs and git diff as gd

@kujiy
Copy link
Author

kujiy commented Apr 15, 2016

alias gfp="git fetch --prune"

@kujiy
Copy link
Author

kujiy commented Apr 15, 2016

Add git branch, git pull, git push origin *

@kujiy
Copy link
Author

kujiy commented Apr 15, 2016

Checkout a feature branch(not specified, I don't care about it because I don't pull two or more branches at the same time)

alias gcf1="git checkout $(git branch | grep feature | tail -1)"
alias gff1="git flow feature finish -F $(git branch | grep feature | tail -1 | sed s/feature\\/// | sed s/*//)"

@kujiy
Copy link
Author

kujiy commented Apr 15, 2016

alias gaa="git add -A"
ga() { git add $@; }

gc() { git commit -m "$@"; }

@kujiy
Copy link
Author

kujiy commented Apr 15, 2016

alias gau="git add -u"

@kujiy
Copy link
Author

kujiy commented May 19, 2016

# alias gs="git status"   # Unfortunately Ghost Script used `gs` `gst` already.
alias gss="git status"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment