My git config for fish shell
########## | |
## Diff ## | |
########## | |
abbr -a gd "git diff --ignore-all-space" | |
abbr -a gdc "git diff --ignore-all-space --staged" | |
############ | |
## Commit ## | |
############ | |
abbr -a gc "git commit" | |
abbr -a gcn "git commit --no-verify" | |
abbr -a gca "git commit --amend" | |
abbr -a gcan "git commit --amend --no-verify" | |
abbr -a gcah "git commit --amend --reuse-message=HEAD" | |
abbr -a gcm "git commit --message " | |
# Temporary commit with current time in its message | |
abbr -a gcmt "git commit --message (date '+[ci skip] %Y-%m-%d %H:%M:%S')" | |
######### | |
## Add ## | |
######### | |
abbr -a ga "git add" | |
abbr -a gau "git add --update" | |
abbr -a ga. "git add ." | |
abbr -a gap "git add --patch" | |
set -ul git_status_changes "git status --porcelain=v1 | \ | |
grep --invert-match \ | |
--extended-regexp \ | |
'^[MADR] '" | |
set -ul fzf_git_status_select "fzf --print0 \ | |
--multi \ | |
--exact \ | |
--preview 'git diff --ignore-all-space --color -- {2} | tail -n +5' | \ | |
gcut --zero-terminated --characters=4-" | |
# Select files to stage | |
alias gas="$git_status_changes | $fzf_git_status_select | xargs -0 git add --" | |
# Select files and then hunks to stage | |
alias gaps="$git_status_changes | $fzf_git_status_select | xargs -0 -o git add --patch --" | |
########## | |
## Push ## | |
########## | |
abbr -a gp "git push --follow-tags" | |
abbr -a gpf "git push --follow-tags --force" | |
abbr -a gpd "git push --delete origin " | |
alias gpu="git rev-parse --abbrev-ref HEAD | \ | |
xargs git push --set-upstream origin" | |
########## | |
## Pull ## | |
########## | |
abbr -a gpl "git pull" | |
abbr -a gplr "git pull --rebase" | |
########### | |
## Reset ## | |
########### | |
abbr -a grs "git reset" | |
abbr -a grsh "git reset HEAD" | |
# Select staged files to reset HEAD | |
abbr -a grshs "git status --porcelain=v1 | \ | |
grep --extended-regexp '^(M |MM) ' | \ | |
fzf --print0 \ | |
--multi \ | |
--exact \ | |
--preview 'git diff --staged --ignore-all-space --color -- {2}' | \ | |
gcut --zero-terminated --characters=4- | \ | |
xargs -0 git reset HEAD" | |
############ | |
## Rebase ## | |
############ | |
abbr -a gr "git rebase" | |
abbr -a grc "git rebase --continue" | |
abbr -a gri "git rebase --interactive" | |
abbr -a grm "git rebase master" | |
abbr -a grio "git rebase --interactive origin/master" | |
set -ul git_log_oneline_format '%C(green)%h%C(red)%d %C(blue)%s %C(black)%C(dim)(%cr)%Creset' | |
set -ul git_log_short_format '%C(green)%h %C(blue)%an %C(black)%C(dim)%cr%C(reset)%C(red)%d%C(reset)%n%w(80, 4, 4)%s%n%+b' | |
# Select a start commit for rebase | |
alias gris="git --no-pager log \ | |
--max-count=500 \ | |
--color \ | |
--format='$git_log_oneline_format' | \ | |
fzf --exact \ | |
--ansi \ | |
--print0 \ | |
--layout=reverse \ | |
--nth='2..-4' \ | |
--preview 'git show --color --stat {1}' | \ | |
gcut --zero-terminated \ | |
--delimiter=' ' \ | |
--fields=1 | \ | |
xargs -0 -o -I {} git rebase --interactive {}^" | |
############ | |
## Revert ## | |
############ | |
abbr -a grv "git revert" | |
abbr -a grvn "git revert --no-commit" | |
########### | |
## Stash ## | |
########### | |
abbr -a gt "git stash" | |
abbr -a gtk "git stash --keep-index" | |
abbr -a gtp "git stash pop" | |
abbr -a gts "git stash show --patch" | |
abbr -a gtd "git stash drop" | |
############ | |
## Branch ## | |
############ | |
abbr -a gb "git branch" | |
abbr -a gbd "git branch --delete" | |
abbr -a gbdf "git branch --delete --force" | |
# Select branch to delete | |
alias gbds "git branch --list | \ | |
fzf --print0 | \ | |
xargs -0 git branch --delete" | |
# Select branch to force-delete | |
alias gbdfs "git branch --list | \ | |
fzf --print0 | \ | |
xargs -0 git branch --delete --force" | |
########### | |
## Merge ## | |
########### | |
abbr -a gm "git merge" | |
############## | |
## Checkout ## | |
############## | |
abbr -a ge "git checkout" | |
# Switch to previous branch | |
abbr -a ge- "git checkout -" | |
abbr -a ge. "git checkout ." | |
alias ges "git diff --name-only | \ | |
fzf --print0 --exact | \ | |
xargs -0 git checkout" | |
alias gebs "git branch --list --color | \ | |
fzf --exact \ | |
--ansi \ | |
--print0 \ | |
--preview-window=right:60%:wrap | |
--preview 'echo \"{}\" | \ | |
tr -d \"* \" | \ | |
xargs git log --color --format=\"$git_log_short_format\" --max-count=5' | \ | |
xargs git checkout" | |
abbr -a geb "git checkout -b" | |
######### | |
## Log ## | |
######### | |
abbr -a gl "git log --format='$git_log_short_format'" | |
abbr -a glg "git log --format='$git_log_short_format' --grep" | |
############ | |
## Bisect ## | |
############ | |
abbr -a gbi "git bisect" | |
abbr -a gbir "git bisect reset" | |
abbr -a gbi+ "git bisect good" | |
abbr -a gbi- "git bisect bad" | |
########### | |
## Other ## | |
########### | |
# List stashed changed + git status | |
function gs | |
git --no-pager stash list | |
git status $argv | |
end | |
# Create new local branch and set upstream to origin/$branch | |
function gbn | |
git checkout -b $argv | |
git branch --set-upstream-to=origin/$argv | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment