Last active
January 19, 2024 19:08
-
-
Save RomanPodkovyrin/267a0e60151555c57ba00a0c2b569000 to your computer and use it in GitHub Desktop.
Git Alias
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
# Logging Aliases | |
git config --global alias.ll 'log --oneline' | |
git config --global alias.plog 'log --graph --pretty="format:%C(red)%d%C(reset) %C(yellow)%h%C(reset) %ar %C(green)%aN%C(reset) %s"' | |
git config --global alias.llog 'log --color --graph --pretty=format:"%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset" --abbrev-commit' | |
git config --global alias.tlog 'log --stat --since="1 Day Ago" --graph --pretty=oneline --abbrev-commit --date=relative' | |
git config --global alias.last 'log -1 HEAD --stat' | |
git config --global alias.mylog '!git log --author="$(git config user.name)" --graph --pretty="format:%C(red)%d%C(reset) %C(yellow)%h%C(reset) %ar %C(green)%aN%C(reset) %s"' | |
# User statistics and info | |
git config --global alias.gl 'config --global -l' # lists user configs | |
git config --global alias.rank 'shortlog -sn --no-merges' | |
git config --global alias.aliases "config --get-regex 'alias*'" # List all aliases | |
# Branch Info | |
git config --global alias.lb 'branch --format="%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(contents:subject) %(color:green)(%(committerdate:relative)) [%(authorname)]" --sort=-committerdate' # List all branches | |
# Shortening aliases | |
git config --global alias.co checkout | |
git config --global alias.br branch | |
git config --global alias.ci commit | |
git config --global alias.st status | |
git config --global alias.d 'diff' | |
# Feature improving aliases | |
git config --global alias.cob 'checkout -b' # Create new branch and switch to it | |
git config --global alias.del 'branch -D' # delete branch git del feat/temp | |
# Finds default branch name | |
git config --global alias.default '!git symbolic-ref refs/remotes/origin/HEAD | sed "s@^refs/remotes/origin/@@"' | |
# Pull changes for a branch and rebase them into our working directory | |
git config --global alias.pullin '!f() { DEFAULT=$(git default); git fetch origin && git rebase origin/${1-$DEFAULT}; };f' | |
# Take all uncommitted and un-staged changes currently in the working directory and add them to the previous commit | |
git config --global alias.caa 'commit -a --amend -C HEAD' | |
# Mistake correction aliases | |
git config --global alias.undo 'reset HEAD~1 --mixed' # Rollback changes previous commit moved into staging area | |
git config --global alias.rh '!git reset --hard' # clean all staged changes | |
# hard reset to branch origin | |
git config --global alias.oops '!f() { DEFAULT=$(git rev-parse --abbrev-ref HEAD); git reset --hard origin/${1-$DEFAULT}; };f' | |
# Funny/stupid | |
git config --global alias.paid push | |
# Branch naming conventional commites | |
# git feat name => feat/name | |
git config --global alias.feat '!f() { NAME=${1}; git checkout -b feat/$NAME; };f' | |
# git feat name 5110 => feat/h-5110-name | |
# git config --global alias.feat '!f() { WORKNUM=${2-'000'}; NAME=${1}; git checkout -b feat/gf-$WORKNUM-$NAME; };f' | |
# git fix name => fix/name | |
git config --global alias.fix '!f() { NAME=${1}; git checkout -b fix/$NAME; };f' | |
# git docs name => docs/name | |
git config --global alias.docs '!f() { NAME=${1}; git checkout -b docs/$NAME; };f' | |
# git refactor name => refactor/name | |
git config --global alias.refactor '!f() { NAME=${1}; git checkout -b refactor/$NAME; };f' | |
# git test name => test/name | |
git config --global alias.test '!f() { NAME=${1}; git checkout -b test/$NAME; };f' | |
# git chore name => chore/name | |
git config --global alias.chore '!f() { NAME=${1}; git checkout -b chore/$NAME; };f' | |
# git config name => config/name | |
git config --global alias.config '!f() { NAME=${1}; git checkout -b config/$NAME; };f' | |
# Other | |
git config --global alias.rv 'remote -v' # lists configured remote repos | |
git config --global alias.dv 'difftool -t vimdiff -y' | |
git config --global alias.se '!git rev-list --all | xargs git grep -F' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment