Created
May 19, 2023 15:54
-
-
Save adsteel/71a82536ea3df6799c1017ff8e447d71 to your computer and use it in GitHub Desktop.
Git ZSH profile helpers
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
alias gm="git commit -m " | |
alias grim="git rebase -i main" | |
alias gcom="git checkout main" | |
alias gam="git commit --amend" | |
alias grc="git rebase --continue" | |
alias gra="git rebase --abort" | |
alias gsoft!="git reset --soft HEAD^" | |
alias gcp="git cherry-pick" | |
alias gcpc="git cherry-pick --continue" | |
alias gcpa="git cherry-pick --abort" | |
alias glogx="git log --graph --pretty=format:'%Cred%h%Creset%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative" | |
alias glog="git log --graph --pretty=format:'%Cred%h%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative" | |
git_commit_fzf() { | |
# optional $1 is the number of commits you want to show | |
if [ "" = "$1" ]; then | |
depth="10" | |
else | |
depth=$1 | |
fi | |
git log HEAD~$depth..HEAD --oneline --decorate | fzf --preview='git show $(echo {} | cut -f 1 -d " ")' | cut -f 1 -d " "; | |
} | |
gric() { git rebase -i $(git_commit_fzf $1); } | |
grib() { git rebase -i $(git branch | fzf); } | |
gco() { git checkout $1; } | |
gcb() { git checkout $(git branch | fzf); } | |
gcc() { git checkout $(git_commit_fzf $1); } | |
gbd() { | |
branch=$(git branch | grep -v main | fzf --preview="echo 'git branch -D{}'" | awk '{$1=$1};1') | |
echo -n "Delete branch ${(%)COLOR_GIT}$branch${(%)COLOR_DEF}?\nEnter yes/no: " | |
read -r confirm | |
if [[ $confirm == *y* ]]; then | |
git branch -D $branch | |
else | |
echo "Exiting" | |
return | |
fi | |
# git branch -D ; | |
} | |
gfresh() { | |
git rm -r --cached . | |
git add . | |
git commit -am '[chore] reset git cache' -m 'This aligns the checked in files with .gitignore' | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment