Last active
May 3, 2021 21:29
-
-
Save danini-the-panini/6d9852bccc092133788cf9e7aeaacca0 to your computer and use it in GitHub Desktop.
Powershell Github aliases ported from oh-my-zsh git plugin
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
Function current_branch { git rev-parse --abbrev-ref HEAD } | |
Function ga { git add @Args } | |
Function gau { git add --update @Args } | |
Function gaa { git add --all @Args } | |
Function gapa { git add --patch @Args } | |
Function gb { git branch @Args } | |
Function gba { git branch -a @Args } | |
Function gbd { git branch -d @Args } | |
Function gbl { git blame -b -w @Args } | |
Function gbnm { git branch --no-merged @Args } | |
Function gbr { git branch --remote @Args } | |
Function gbs { git bisect @Args } | |
Function gbsb { git bisect bad @Args } | |
Function gbsg { git bisect good @Args } | |
Function gbsr { git bisect reset @Args } | |
Function gbss { git bisect start @Args } | |
Remove-Item alias:\gc -Force | |
Function gc { git commit -v @Args } | |
Function gc! { git commit -v --amend @Args } | |
Function gca { git commit -v -a @Args } | |
Function gca! { git commit -v -a --amend @Args } | |
Function gcan! { git commit -v -a --no-edit --amend @Args } | |
Function gcans! { git commit -v -a -s --no-edit --amend @Args } | |
Function gcam { git commit -a -m @Args } | |
Function gcsm { git commit -s -m @Args } | |
Remove-Item alias:\gcb -Force | |
Function gcb { git checkout -b @Args } | |
Function gcf { git config --list @Args } | |
Function gcl { git clone --recurse-submodules @Args } | |
Function gclean { git clean -id @Args } | |
Function gpristine { git reset --hard; git clean -dffx @Args } | |
Remove-Item alias:\gcm -Force | |
Function gcm { git checkout master @Args } | |
Function gcd { git checkout develop @Args } | |
Function gcmsg { git commit -m @Args } | |
$getBranchesScriptBlock = { | |
param($commandName, $parameterName, $stringMatch) | |
git for-each-ref --format='%(refname:strip=2)' "refs/heads/$stringMatch*" "refs/heads/$stringMatch*/**" && | |
git for-each-ref --format='%(refname:strip=3)' "refs/remotes/*/$stringMatch*" "refs/remotes/*/$stringMatch*/**" | |
} | |
Function gco { | |
[CmdletBinding()] | |
param( | |
[Parameter(Position = 0)] | |
[string]$Branch, | |
[Parameter()] | |
[string]$b | |
) | |
if ("" -eq $b) | |
{ | |
git checkout $Branch | |
} | |
else | |
{ | |
git checkout -b $b | |
} | |
} | |
Register-ArgumentCompleter -CommandName gco -ParameterName Branch -ScriptBlock $getBranchesScriptBlock | |
Function gcount { git shortlog -sn @Args } | |
Function gcp { git cherry-pick @Args } | |
Function gcpa { git cherry-pick --abort @Args } | |
Function gcpc { git cherry-pick --continue @Args } | |
Remove-Item alias:\gcs -Force | |
Function gcs { git commit -S @Args } | |
Function gd { git diff @Args } | |
Function gdca { git diff --cached @Args } | |
Function gdct { git describe --tags $(git rev-list --tags --max-count=1) @Args } | |
Function gds { git diff --staged @Args } | |
Function gdt { git diff-tree --no-commit-id --name-only -r @Args } | |
Function gdw { git diff --word-diff @Args } | |
Function gf { git fetch @Args } | |
Function gfa { git fetch --all --prune @Args } | |
Function gfo { git fetch origin @Args } | |
Function gg { git gui citool @Args } | |
Function gga { git gui citool --amend @Args } | |
Function ggpnp { git pull origin $(current_branch); git push origin $(current_branch) @Args } | |
Function ggpull { git pull origin $(current_branch) @Args } | |
Function ggl { git pull origin $(current_branch) @Args } | |
Function ggpur { git pull --rebase origin $(current_branch) @Args } | |
Function ggu { git pull --rebase origin $(current_branch) @Args } | |
Function glum { git pull upstream master @Args } | |
Function ggpush { git push origin $(current_branch) @Args } | |
Function ggp { git push origin $(current_branch) @Args } | |
Function ggfl { git push --force-with-lease origin $Args[0]/$(current_branch) } | |
Function ggsup { git branch --set-upstream-to=origin/$(current_branch) @Args } | |
Function gpsup { git push --set-upstream origin $(current_branch) @Args } | |
Function ghh { git help @Args } | |
Function gignore { git update-index --assume-unchanged @Args } | |
Function gignored { git ls-files -v @Args } | |
Function gk { \gitk --all --branches @Args } | |
Function gke { \gitk --all $(git log -g --pretty=%h) @Args } | |
Remove-Item alias:\gl -Force | |
Function gl { git pull @Args } | |
Function glg { git log --stat @Args } | |
Function glgg { git log --graph @Args } | |
Function glgga { git log --graph --decorate --all @Args } | |
Function glgm { git log --graph --max-count=10 @Args } | |
Function glgp { git log --stat -p @Args } | |
Function glo { git log --oneline --decorate @Args } | |
Function glog { git log --oneline --decorate --graph @Args } | |
Function glol { git log --graph --pretty=\'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset\' @Args } | |
Function glola { git log --graph --pretty=\'%Cred%h%Creset -%C(auto)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset\' --all @Args } | |
Function glp { _git_log_prettily (Also: "git log --pretty=$1") @Args } | |
Remove-Item alias:\gm -Force | |
Function gm { git merge @Args } | |
Function gma { git merge --abort @Args } | |
Function gmom { git merge origin/master @Args } | |
Function gmt { git mergetool --no-prompt @Args } | |
Function gmtvim { git mergetool --no-prompt --tool=vimdiff @Args } | |
Function gmum { git merge upstream/master @Args } | |
Remove-Item alias:\gp -Force | |
Function gp { git push @Args } | |
Function gpd { git push --dry-run @Args } | |
Function gpoat { git push origin --all; git push origin --tags @Args } | |
Function gpu { git push upstream @Args } | |
Function gpv { git push -v @Args } | |
Function gr { git remote @Args } | |
Function gra { git remote add @Args } | |
Function grb { git rebase @Args } | |
Function grba { git rebase --abort @Args } | |
Function grbc { git rebase --continue @Args } | |
Function grbd { git rebase develop @Args } | |
Function grbi { git rebase -i @Args } | |
Function grbm { git rebase master @Args } | |
Function grbs { git rebase --skip @Args } | |
Function grh { git reset (Also: "git reset HEAD") @Args } | |
Function grhh { git reset --hard (Also: "git reset HEAD --hard") @Args } | |
Function grmv { git remote rename @Args } | |
Function grrm { git remote remove @Args } | |
Function grs { git restore @Args } | |
Function grset { git remote set-url @Args } | |
Function grt { Set-Location $((git rev-parse --show-toplevel) -OR (".")) } | |
Function gru { git reset -- @Args } | |
Function grup { git remote update @Args } | |
Function grv { git remote -v @Args } | |
Function gsb { git status -sb @Args } | |
Function gsd { git svn dcommit @Args } | |
Function gsi { git submodule init @Args } | |
Function gsps { git show --pretty=short --show-signature @Args } | |
Function gsr { git svn rebase @Args } | |
Function gss { git status -s @Args } | |
Function gst { git status @Args } | |
Function gsta { git stash save @Args } | |
Function gstaa { git stash apply @Args } | |
Function gstd { git stash drop @Args } | |
Function gstl { git stash list @Args } | |
Function gstp { git stash pop @Args } | |
Function gstc { git stash clear @Args } | |
Function gsts { git stash show --text @Args } | |
Function gsu { git submodule update @Args } | |
Function gts { git tag -s @Args } | |
Function gunignore { git update-index --no-assume-unchanged @Args } | |
Function gunwip { git log -n 1 | grep -q -c "--wip--"; git reset HEAD~1 @Args } | |
Function gup { git pull --rebase @Args } | |
Function gupv { git pull --rebase -v @Args } | |
Function gvt { git verify-tag @Args } | |
Function gwch { git whatchanged -p --abbrev-commit --pretty=medium @Args } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment