Last active
October 5, 2023 19:27
-
-
Save eighteyes/86249174f850f4cd5808 to your computer and use it in GitHub Desktop.
Big List of Git Aliases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# git | |
alias glm='log --graph --abbrev-commit --decorate --date=relative --format=format:"%C(yellow)%h%C(reset) - %C(blue)(%ar)%C(reset)%C(dim white) %an%C(reset) %C(white)%s%C(reset) %C(auto)%d%C(reset)" --all' | |
#this branch story | |
function __gbstory(){ | |
git log --graph --oneline --decorate --all $1 HEAD; | |
} | |
alias gbstory=__gbstory | |
## git by day | |
function __gbd(){ | |
a="" | |
b="" | |
for i in $(seq 1 10) | |
do | |
b=$(git diff --shortstat "@{ $i day ago }") | |
if [[ "$b" != "$a" ]]; then | |
echo $i "day ago" $b | |
fi | |
a=$b | |
done | |
} | |
alias gbdr=__gbd | |
# open all conflicts | |
function __gcon(){ | |
git diff --name-only --diff-filter=U | xargs -I {} atom {} | |
} | |
alias gcon=gcon() | |
alias gbs='git bisect start' | |
alias gbb='git bisect bad' | |
alias gbg='git bisect good' | |
alias gbsk='git bisect skip' | |
alias gbv='git bisect visualize' | |
alias gbl='git bisect log' | |
alias gbre='git bisect reset' | |
alias gbd='git log --pretty=format:"%ad %s" --date="short"' | |
alias glad='git log --pretty=format:"%an %ar %s" --date="short"' | |
## Remove all merged branches | |
alias gpurge="git branch --merged | grep -v -E '\*|master|dev|release' | xargs -n 1 git branch -d" | |
## Remove all unmerged branches (warning, might delete work in progress) | |
alias gparge="git branch --no-merged | grep -v -E '\*|master|dev|release' | xargs -n 1 git branch -D" | |
# repeat | |
alias gdp="git checkout dev; git pull;" | |
# find lost branches | |
alias glb="git branch --no-merged" | |
alias grd="git rebase dev" | |
alias gpod="git pull origin dev" | |
alias gsh='git show' | |
alias grh='git reset --hard' | |
alias gsa='git stash apply' | |
alias gst='git stash' | |
alias ga='git add .' | |
alias gds='git diff --cached' | |
alias gundo='git reset --soft "HEAD^"' | |
# look at staged changes | |
# Show files in log | |
alias gl='git log' | |
alias gmine="git log --follow --author='Sean' --oneline" | |
alias glf='git log --oneline --name-only' | |
alias glg='git log --graph --oneline --decorate --all' | |
alias gls='git log --pretty=format:"%C(yellow)%h%Cred%d\\ %Creset%s%Cblue\\ [%cn]" --decorate' | |
# What files were touched n number of commits | |
alias glfn='git log --oneline --name-only -n' | |
# Open log files x number of times back : glo 1 | |
function __glo(){ | |
atom `git log --name-only -n $1 --format=format: | xargs`; | |
} | |
alias glo='__glo' | |
# Open files worked on this branch | |
function __glob(){ | |
glo `git log dev..$(parse_git_branch) --pretty=oneline | wc -l` | |
} | |
alias glob='__glob' | |
# Open and grep log files x number of times back : glgo 1 query | |
function __glgo(){ | |
atom `git log --name-only -n $1 --grep '$2' --format=format: | xargs`; | |
} | |
alias glgo='__glgo' | |
# Open staged files | |
function __gso(){ | |
atom `git status -s | cut -c 4- | xargs`; | |
} | |
alias gso='__gso' | |
# Open staged grepped files | |
function __gsgo(){ | |
atom `git diff -G '$1' --name-only`; | |
} | |
alias gsgo='__gsgo' | |
# Open grepped files to line : ggo foo | |
function __ggo(){ | |
atom `git grep -n $1 | cut -f 1,2 -d ":"` | |
} | |
alias ggo='__ggo' | |
# Open grepped files to line : ggo foo | |
function __gwo(){ | |
echo "hi" | |
} | |
alias gwo='__gwo' | |
# Git, where was this changed? | |
function __gw(){ | |
git grep $1 $(git rev-list --all); | |
} | |
alias gw='__gw' | |
# And lets only look at certain files : gwf .error '*.css' | |
function __gwf(){ | |
git grep $1 $(git rev-list --all) -- $2; | |
} | |
alias gwf='__gwf' | |
# use when you made commits behind origin and forgot to push | |
function __gweave(){ | |
git checkout -b weave; | |
git checkout dev; | |
git reset @{$1} --hard; | |
git pull; | |
git checkout weave; | |
git rebase dev; | |
git checkout dev | |
git merge weave -m "Merge Weave"; | |
git branch -D weave; | |
} | |
alias gweave='__gweave' | |
alias gs='git status' | |
alias gd='git diff' | |
alias gdt='git diff staged' | |
#git commits | |
alias gca='git commit -a; git log -n 1 --pretty=%H | tr -d \n | pbcopy;' | |
alias gc+='git commit --amend' | |
alias gcm='git commit -m'; | |
# go back to last branch | |
alias gc='git checkout -' | |
alias gz='git reset --soft "HEAD^"' | |
alias gb='git branch' | |
# see remotes | |
alias gbr='git branch -r' | |
alias gb-='git branch -d' | |
alias gc='git checkout' | |
alias gc-='git checkout --' | |
alias gbn='git checkout -b' | |
alias gdl='git diff HEAD^ HEAD' | |
alias gss='git status -s' | |
alias gdel='git branch -D' | |
# Completely refresh this branch | |
alias gdelthis='BRANCH=$(parse_git_branch);git reset --hard;git checkout dev;git branch -D $BRANCH;git pull;git checkout $BRANCH' | |
# Copy working files to clipboard | |
alias gsc='git status -s | cut -c 4- | pbcopy' | |
alias grc='git rebase --continue' | |
alias gcd='git checkout dev; git pull;' | |
# Show diff for last commit | |
alias gld='git log -1 -p' | |
# goto issues | |
alias gph='git push' | |
alias gpl='git pull' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment