├── .editorconfig ├── LICENSE ├── README.md ├── src ├── git-aliases.psm1 ├── utils.ps1 ├── git-aliases.psd1 └── aliases.ps1 └── aliases.md /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = tab 5 | indent_size = 4 6 | charset = utf-8 7 | insert_final_newline = true 8 | trim_trailing_whitespace = true 9 | 10 | [*.md] 11 | trim_trailing_whitespace = false 12 | 13 | [{*.{coffee,cson,yml,yaml,jade,pug,rb,gemspec},{package,bower}.json,Rakefile,Gemfile}] 14 | indent_style = space 15 | indent_size = 2 16 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Saran Tanpituckpong 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Git aliases for PowerShell 2 | [![license](https://img.shields.io/github/license/gluons/powershell-git-aliases.svg?style=flat-square)](./LICENSE) 3 | [![PowerShell Gallery](https://img.shields.io/powershellgallery/v/git-aliases.svg?style=flat-square)](https://www.powershellgallery.com/packages/git-aliases/) 4 | [![PowerShell Gallery](https://img.shields.io/powershellgallery/dt/git-aliases.svg?style=flat-square)](https://www.powershellgallery.com/packages/git-aliases/) 5 | 6 | A [PowerShell](https://microsoft.com/powershell) module that provide partial **[Git](https://git-scm.com/)** aliases from [Oh My Zsh](https://github.com/robbyrussell/oh-my-zsh)'s [git plugin](https://github.com/robbyrussell/oh-my-zsh/tree/master/plugins/git/). 7 | 8 | > ℹ️ This module will replace some built-in PowerShell aliases with our Git aliases to **prevent** [conflict](https://github.com/gluons/powershell-git-aliases/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3Aconflict). 9 | 10 | ## ⚙️ Installation 11 | 12 | Install from [PowerShell Gallery](https://www.powershellgallery.com/packages/git-aliases/) 13 | 14 | ```powershell 15 | Install-Module git-aliases -Scope CurrentUser -AllowClobber 16 | ``` 17 | 18 | Or from [Scoop](https://github.com/ScoopInstaller/Extras/blob/master/bucket/git-aliases.json) 19 | 20 | ```powershell 21 | scoop bucket add extras 22 | scoop install git-aliases 23 | ``` 24 | 25 | --- 26 | 27 | ⚠️ If you haven't allowed script execution policy, set your script execution policy to `RemoteSigned` or `Unrestricted`. 28 | 29 | ```powershell 30 | Set-ExecutionPolicy RemoteSigned -Scope CurrentUser 31 | ``` 32 | 33 | ## 🛂 Usage 34 | 35 | You have to import the module to use `git-aliases`. 36 | 37 | Add below command into your PowerShell profile. 38 | 39 | ```powershell 40 | Import-Module git-aliases -DisableNameChecking 41 | ``` 42 | 43 | Then restart your PowerShell. 44 | Now you can use Git aliases. 45 | 46 | --- 47 | 48 | ⚠️ If you don't have PowerShell profile yet, create it with below command! 49 | 50 | ```powershell 51 | New-Item -ItemType File $profile 52 | ``` 53 | -------------------------------------------------------------------------------- /src/git-aliases.psm1: -------------------------------------------------------------------------------- 1 | . $PSScriptRoot\aliases.ps1 2 | 3 | $FunctionsToExport = @( 4 | 'Get-Git-CurrentBranch', 5 | 'Get-Git-Aliases', 6 | 'Get-Git-MainBranch', 7 | 'g', 8 | 'ga', 9 | 'gaa', 10 | 'gapa', 11 | 'gau', 12 | 'gb', 13 | 'gba', 14 | 'gbd', 15 | 'gbda', 16 | 'gbl', 17 | 'gbnm', 18 | 'gbr', 19 | 'gbs', 20 | 'gbsb', 21 | 'gbsg', 22 | 'gbsr', 23 | 'gbss', 24 | 'gc', 25 | 'gc!', 26 | 'gcn!', 27 | 'gca', 28 | 'gcam', 29 | 'gca!', 30 | 'gcan!', 31 | 'gcans!', 32 | 'gcb', 33 | 'gcf', 34 | 'gcl', 35 | 'gclean', 36 | 'gcm', 37 | 'gcd', 38 | 'gcmsg', 39 | 'gco', 40 | 'gcount', 41 | 'gcp', 42 | 'gcpa', 43 | 'gcpc', 44 | 'gcs', 45 | 'gd', 46 | 'gds', 47 | 'gdca', 48 | 'gdt', 49 | 'gdw', 50 | 'gf', 51 | 'gfa', 52 | 'gfo', 53 | 'gg', 54 | 'gga', 55 | 'ggf', 56 | 'ggfl', 57 | 'ghh', 58 | 'ggsup', 59 | 'gpsup', 60 | 'gignore', 61 | 'gignored', 62 | 'gl', 63 | 'glg', 64 | 'glgg', 65 | 'glgga', 66 | 'glgm', 67 | 'glgp', 68 | 'glo', 69 | 'glog', 70 | 'gloga', 71 | 'glol', 72 | 'glola', 73 | 'gm', 74 | 'gmom', 75 | 'gmt', 76 | 'gmtvim', 77 | 'gmum', 78 | 'gp', 79 | 'gpd', 80 | 'gpf', 81 | 'gpf!', 82 | 'gpoat', 83 | 'gpr', 84 | 'gpra', 85 | 'gpristine', 86 | 'gprv', 87 | 'gpu', 88 | 'gpv', 89 | 'gr', 90 | 'gra', 91 | 'grb', 92 | 'grba', 93 | 'grbc', 94 | 'grbi', 95 | 'grbm', 96 | 'grbs', 97 | 'grh', 98 | 'grhh', 99 | 'grmv', 100 | 'groh', 101 | 'grrm', 102 | 'grset', 103 | 'grs', 104 | 'grst', 105 | 'grt', 106 | 'gru', 107 | 'grup', 108 | 'grv', 109 | 'gsb', 110 | 'gsd', 111 | 'gsh', 112 | 'gsi', 113 | 'gsps', 114 | 'gsr', 115 | 'gss', 116 | 'gst', 117 | 'gsta', 118 | 'gstaa', 119 | 'gstd', 120 | 'gstl', 121 | 'gstp', 122 | 'gstc', 123 | 'gsts', 124 | 'gsu', 125 | 'gsw', 126 | 'gswc', 127 | 'gts', 128 | 'gunignore', 129 | 'gunwip', 130 | 'gup', 131 | 'gupa', 132 | 'gupv', 133 | 'glum', 134 | 'gvt', 135 | 'gwch', 136 | 'gwip', 137 | 'ggl', 138 | 'ggp', 139 | 'ggpnp', 140 | 'gprom', 141 | 'gwt', 142 | 'gwta', 143 | 'gwtls', 144 | 'gwtmv', 145 | 'gwtrm' 146 | ) 147 | 148 | Export-ModuleMember -Function $FunctionsToExport 149 | -------------------------------------------------------------------------------- /src/utils.ps1: -------------------------------------------------------------------------------- 1 | <# 2 | .SYNOPSIS 3 | Get current git branch. 4 | #> 5 | function Get-Git-CurrentBranch { 6 | git symbolic-ref --quiet HEAD *> $null 7 | 8 | if ($LASTEXITCODE -eq 0) { 9 | return git rev-parse --abbrev-ref HEAD 10 | } else { 11 | return 12 | } 13 | } 14 | 15 | function Get-Git-MainBranch { 16 | git rev-parse --git-dir *> $null 17 | 18 | if ($LASTEXITCODE -ne 0) { 19 | return 20 | } 21 | 22 | $branches = @('main', 'trunk') 23 | 24 | foreach ($branch in $branches) { 25 | & git show-ref -q --verify refs/heads/$branch 26 | 27 | if ($LASTEXITCODE -eq 0) { 28 | return $branch 29 | } 30 | } 31 | 32 | return 'master' 33 | } 34 | 35 | # Don't add `Remove-Alias` on PowerShell >= 6. 36 | # PowerShell >= 6 already has built-in `Remove-Alias`. 37 | # Let use built-in `Remove-Alias` on PowerShell >= 6. 38 | if ($PSVersionTable.PSVersion.Major -le 5) { 39 | function Remove-Alias ([string] $AliasName) { 40 | while (Test-Path Alias:$AliasName) { 41 | Remove-Item Alias:$AliasName -Force 2> $null 42 | } 43 | } 44 | } 45 | 46 | function Format-AliasDefinition { 47 | param ( 48 | [Parameter(Mandatory = $true)][string] $Definition 49 | ) 50 | 51 | $definitionLines = $Definition.Trim() -split "`n" | ForEach-Object { 52 | $line = $_.TrimEnd() 53 | 54 | # Trim 1 indent 55 | if ($_ -match "^`t") { 56 | return $line.Substring(1) 57 | } 58 | elseif ($_ -match '^ ') { 59 | return $line.Substring(4) 60 | } 61 | 62 | return $line 63 | 64 | } 65 | 66 | return $definitionLines -join "`n" 67 | } 68 | 69 | <# 70 | .SYNOPSIS 71 | Get git aliases' definition. 72 | .DESCRIPTION 73 | Get definition of all git aliases or specific alias. 74 | .EXAMPLE 75 | PS C:\> Get-Git-Aliases 76 | Get definition of all git aliases. 77 | .EXAMPLE 78 | PS C:\> Get-Git-Aliases -Alias gst 79 | Get definition of `gst` alias. 80 | #> 81 | function Get-Git-Aliases ([string] $Alias) { 82 | $esc = [char] 27 83 | $green = 32 84 | $magenta = 35 85 | 86 | $Alias = $Alias.Trim() 87 | $blacklist = @( 88 | 'Get-Git-CurrentBranch', 89 | 'Remove-Alias', 90 | 'Format-AliasDefinition', 91 | 'Get-Git-Aliases', 92 | 'Write-Host-Deprecated' 93 | ) 94 | $aliases = Get-Command -Module git-aliases | Where-Object { $_ -notin $blacklist } 95 | 96 | if (-not ([string]::IsNullOrEmpty($Alias))) { 97 | $foundAliases = $aliases | Where-Object -Property Name -Value $Alias -EQ 98 | 99 | if ($foundAliases -is [array]) { 100 | return Format-AliasDefinition($foundAliases[0].Definition) 101 | } 102 | else { 103 | return Format-AliasDefinition($foundAliases.Definition) 104 | } 105 | } 106 | 107 | $aliases = $aliases | ForEach-Object { 108 | $name = $_.Name 109 | $definition = Format-AliasDefinition($_.Definition) 110 | $definition = "$definition`n" # Add 1 line break for some row space 111 | 112 | return [PSCustomObject]@{ 113 | Name = $name 114 | Definition = $definition 115 | } 116 | } 117 | 118 | $cols = @( 119 | @{ 120 | Name = 'Name' 121 | Expression = { 122 | # Print alias name in green 123 | "$esc[$($green)m$($_.Name)$esc[0m" 124 | } 125 | }, 126 | @{ 127 | Name = 'Definition' 128 | Expression = { 129 | # Print alias definition in yellow 130 | "$esc[$($magenta)m$($_.Definition)$esc[0m" 131 | } 132 | } 133 | ) 134 | 135 | return Format-Table -InputObject $aliases -AutoSize -Wrap -Property $cols 136 | } 137 | 138 | <# 139 | .SYNOPSIS 140 | Print deprecated message. 141 | .DESCRIPTION 142 | Print a colored message telling that a specific alias ($previous) 143 | is deprecated, suggesting the use of another alias ($next). 144 | .EXAMPLE 145 | PS C:\> Write-Host-Deprecated "gup" "gpr" 146 | [git-aliases] gup is a deprecated alias, use "gpr" instead. 147 | #> 148 | function Write-Host-Deprecated { 149 | param ( 150 | [Parameter(Mandatory = $true)][string] $previous, 151 | [Parameter(Mandatory = $true)][string] $next 152 | ) 153 | 154 | Write-Host "[git-aliases] " -ForegroundColor Yellow -NoNewLine 155 | Write-Host "${previous}" -ForegroundColor Red -NoNewLine 156 | Write-Host " is a deprecated alias, use " -ForegroundColor Yellow -NoNewLine 157 | Write-Host """${next}""" -ForegroundColor Green -NoNewLine 158 | Write-Host " instead.`n" -ForegroundColor Yellow 159 | } 160 | -------------------------------------------------------------------------------- /src/git-aliases.psd1: -------------------------------------------------------------------------------- 1 | # 2 | # Module manifest for module 'git-aliases' 3 | # 4 | # Generated by: Saran Tanpituckpong 5 | # 6 | # Generated on: 6/3/17 7 | # 8 | 9 | @{ 10 | 11 | # Script module or binary module file associated with this manifest. 12 | RootModule = 'git-aliases.psm1' 13 | 14 | # Version number of this module. 15 | ModuleVersion = '0.3.8' 16 | 17 | # Supported PSEditions 18 | # CompatiblePSEditions = @() 19 | 20 | # ID used to uniquely identify this module 21 | GUID = 'fe7345a7-0e7f-43d6-b924-3fe93c8f8fe7' 22 | 23 | # Author of this module 24 | Author = 'Saran Tanpituckpong' 25 | 26 | # Copyright statement for this module 27 | Copyright = '(c) Saran Tanpituckpong. All rights reserved.' 28 | 29 | # Description of the functionality provided by this module 30 | Description = "A PowerShell module that provide partial Git aliases from Oh My Zsh's git plugin." 31 | 32 | # Minimum version of the Windows PowerShell engine required by this module 33 | # PowerShellVersion = '' 34 | 35 | # Name of the Windows PowerShell host required by this module 36 | # PowerShellHostName = '' 37 | 38 | # Minimum version of the Windows PowerShell host required by this module 39 | # PowerShellHostVersion = '' 40 | 41 | # Minimum version of Microsoft .NET Framework required by this module. This prerequisite is valid for the PowerShell Desktop edition only. 42 | # DotNetFrameworkVersion = '' 43 | 44 | # Minimum version of the common language runtime (CLR) required by this module. This prerequisite is valid for the PowerShell Desktop edition only. 45 | # CLRVersion = '' 46 | 47 | # Processor architecture (None, X86, Amd64) required by this module 48 | # ProcessorArchitecture = '' 49 | 50 | # Modules that must be imported into the global environment prior to importing this module 51 | # RequiredModules = @() 52 | 53 | # Assemblies that must be loaded prior to importing this module 54 | # RequiredAssemblies = @() 55 | 56 | # Script files (.ps1) that are run in the caller's environment prior to importing this module. 57 | # ScriptsToProcess = @() 58 | 59 | # Type files (.ps1xml) to be loaded when importing this module 60 | # TypesToProcess = @() 61 | 62 | # Format files (.ps1xml) to be loaded when importing this module 63 | # FormatsToProcess = @() 64 | 65 | # Modules to import as nested modules of the module specified in RootModule/ModuleToProcess 66 | # NestedModules = @() 67 | 68 | # Functions to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no functions to export. 69 | FunctionsToExport = '*' 70 | 71 | # Cmdlets to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no cmdlets to export. 72 | # CmdletsToExport = @() 73 | 74 | # Variables to export from this module 75 | # VariablesToExport = @() 76 | 77 | # Aliases to export from this module, for best performance, do not use wildcards and do not delete the entry, use an empty array if there are no aliases to export. 78 | # AliasesToExport = @() 79 | 80 | # DSC resources to export from this module 81 | # DscResourcesToExport = @() 82 | 83 | # List of all modules packaged with this module 84 | # ModuleList = @() 85 | 86 | # List of all files packaged with this module 87 | # FileList = @() 88 | 89 | # Private data to pass to the module specified in RootModule/ModuleToProcess. This may also contain a PSData hashtable with additional module metadata used by PowerShell. 90 | PrivateData = @{ 91 | 92 | PSData = @{ 93 | 94 | # Tags applied to this module. These help with module discovery in online galleries. 95 | Tags = @('git', 'alias', 'aliases', 'oh-my-zsh') 96 | 97 | # A URL to the license for this module. 98 | LicenseUri = 'https://github.com/gluons/powershell-git-aliases/blob/master/LICENSE' 99 | 100 | # A URL to the main website for this project. 101 | ProjectUri = 'https://github.com/gluons/powershell-git-aliases' 102 | 103 | # A URL to an icon representing this module. 104 | # IconUri = '' 105 | 106 | # ReleaseNotes of this module 107 | # ReleaseNotes = '' 108 | 109 | } # End of PSData hashtable 110 | 111 | } # End of PrivateData hashtable 112 | 113 | # HelpInfo URI of this module 114 | HelpInfoURI = 'https://github.com/gluons/powershell-git-aliases' 115 | 116 | # Default prefix for commands exported from this module. Override the default prefix using Import-Module -Prefix. 117 | # DefaultCommandPrefix = '' 118 | 119 | } 120 | 121 | -------------------------------------------------------------------------------- /aliases.md: -------------------------------------------------------------------------------- 1 | # Git Alias Documentation 2 | 3 | | Alias | Definition | 4 | |--------|-------------| 5 | | `g` | `git $args` | 6 | | `ga` | `git add $args` | 7 | | `gaa` | `git add --all $args` | 8 | | `gapa` | `git add --patch $args` | 9 | | `gau` | `git add --update $args` | 10 | | `gb` | `git branch $args` | 11 | | `gba` | `git branch -a $args` | 12 | | `gbda` | Script to delete merged branches except main branches. | 13 | | `gbl` | `git blame -b -w $args` | 14 | | `gbnm` | `git branch --no-merged $args` | 15 | | `gbr` | `git branch --remote $args` | 16 | | `gbs` | `git bisect $args` | 17 | | `gbsb` | `git bisect bad $args` | 18 | | `gbsg` | `git bisect good $args` | 19 | | `gbsr` | `git bisect reset $args` | 20 | | `gbss` | `git bisect start $args` | 21 | | `gc` | `git commit -v $args` | 22 | | `gc!` | `git commit -v --amend $args` | 23 | | `gca` | `git commit -v -a $args` | 24 | | `gca!` | `git commit -v -a --amend $args` | 25 | | `gcam` | `git commit -a -m $args` | 26 | | `gcan!`| `git commit -v -a --no-edit --amend $args` | 27 | | `gcans!`| `git commit -v -a -s --no-edit --amend $args` | 28 | | `gcb` | `git checkout -b $args` | 29 | | `gcd` | `git checkout develop $args` | 30 | | `gcf` | `git config --list $args` | 31 | | `gcl` | `git clone --recursive $args` | 32 | | `gclean`| `git clean -df $args` | 33 | | `gcm` | Script to checkout the main branch. | 34 | | `gcmsg`| `git commit -m $args` | 35 | | `gcn!` | `git commit -v --no-edit --amend $args` | 36 | | `gco` | `git checkout $args` | 37 | | `gcount`| `git shortlog -sn $args` | 38 | | `gcp` | `git cherry-pick $args` | 39 | | `gcpa` | `git cherry-pick --abort $args` | 40 | | `gcpc` | `git cherry-pick --continue $args` | 41 | | `gcs` | `git commit -S $args` | 42 | | `gd` | `git diff $args` | 43 | | `gdca` | `git diff --cached $args` | 44 | | `gdt` | `git diff-tree --no-commit-id --name-only -r $args` | 45 | | `gdw` | `git diff --word-diff $args` | 46 | | `Get-Git-MainBranch`| Script to determine the main branch of the repository. | 47 | | `gf` | `git fetch $args` | 48 | | `gfa` | `git fetch --all --prune $args` | 49 | | `gfo` | `git fetch origin $args` | 50 | | `gg` | `git gui citool $args` | 51 | | `gga` | `git gui citool --amend $args` | 52 | | `ggf` | Script to force-push the current branch. | 53 | | `ggfl` | Script to force-push with lease the current branch. | 54 | | `ggl` | Script to pull changes from origin for the current branch. | 55 | | `ggp` | Script to push the current branch to origin. | 56 | | `ggsup`| Script to set upstream for the current branch. | 57 | | `ghh` | `git help $args` | 58 | | `gignore`| `git update-index --assume-unchanged $args` | 59 | | `gignored`| Script to list ignored files. | 60 | | `gl` | `git pull $args` | 61 | | `glg` | `git log --stat --color $args` | 62 | | `glgg` | `git log --graph --color $args` | 63 | | `glgga`| `git log --graph --decorate --all $args` | 64 | | `glgm` | `git log --graph --max-count=10 $args` | 65 | | `glgp` | `git log --stat --color -p $args` | 66 | | `glo` | `git log --oneline --decorate --color $args` | 67 | | `glog` | `git log --oneline --decorate --color --graph $args` | 68 | | `gloga`| `git log --oneline --decorate --color --graph --all $args` | 69 | | `glol` | `git log --graph --pretty=format:... $args` | 70 | | `glola`| `git log --graph --pretty=format:... --all $args` | 71 | | `glum` | Script to pull upstream changes for the main branch. | 72 | | `gm` | `git merge $args` | 73 | | `gmom` | Script to merge origin/main branch. | 74 | | `gmt` | `git mergetool --no-prompt $args` | 75 | | `gmtvim`| `git mergetool --no-prompt --tool=vimdiff $args` | 76 | | `gmum` | Script to merge upstream/main branch. | 77 | | `gp` | `git push $args` | 78 | | `gpd` | `git push --dry-run $args` | 79 | | `gpf` | `git push --force-with-lease $args` | 80 | | `gpf!` | `git push --force $args` | 81 | | `gpoat`| Script to push all branches and tags to origin. | 82 | | `gpristine`| Script to reset and clean the repository. | 83 | | `gpsup`| Script to push the current branch and set upstream. | 84 | | `gpu` | `git push upstream $args` | 85 | | `gpv` | `git push -v $args` | 86 | | `gr` | `git remote $args` | 87 | | `gra` | `git remote add $args` | 88 | | `grb` | `git rebase $args` | 89 | | `grba` | `git rebase --abort $args` | 90 | | `grbc` | `git rebase --continue $args` | 91 | | `grbi` | `git rebase -i $args` | 92 | | `grbm` | Script to rebase the main branch. | 93 | | `grbs` | `git rebase --skip $args` | 94 | | `grh` | `git reset $args` | 95 | | `grhh` | `git reset --hard $args` | 96 | | `grmv` | `git remote rename $args` | 97 | | `grrm` | `git remote remove $args` | 98 | | `grs` | `git restore $args` | 99 | | `grset`| `git remote set-url $args` | 100 | | `grt` | Script to change directory to the repository root. | 101 | | `gru` | `git reset -- $args` | 102 | | `grup` | `git remote update $args` | 103 | | `grv` | `git remote -v $args` | 104 | | `gsb` | `git status -sb $args` | 105 | | `gsd` | `git svn dcommit $args` | 106 | | `gsh` | `git show $args` | 107 | | `gsi` | `git submodule init $args` | 108 | | `gsps` | `git show --pretty=short --show-signature $args` | 109 | | `gsr` | `git svn rebase $args` | 110 | | `gss` | `git status -s $args` | 111 | | `gst` | `git status $args` | 112 | | `gsta` | `git stash save $args` | 113 | | `gstaa`| `git stash apply $args` | 114 | | `gstc` | `git stash clear $args` | 115 | | `gstd` | `git stash drop $args` | 116 | | `gstl` | `git stash list $args` | 117 | | `gstp` | `git stash pop $args` | 118 | | `gsts` | `git stash show --text $args` | 119 | | `gsu` | `git submodule update $args` | 120 | | `gsw` | `git switch $args` | 121 | | `gswc` | `git switch --create $args` | 122 | | `gts` | `git tag -s $args` | 123 | | `gunignore`| `git update-index --no-assume-unchanged $args` | 124 | | `gunwip`| Script to remove a WIP commit. | 125 | | `gup` | `git pull --rebase $args` | 126 | | `gupv` | `git pull --rebase -v $args` | 127 | | `gvt` | `git verify-tag $args` | 128 | | `gwch` | `git whatchanged -p --abbrev-commit --pretty=medium $args` | 129 | | `gwip` | Script to create a WIP commit. | 130 | | `gwt` | `git worktree $args` | 131 | | `gwta` | `git worktree add $args` | 132 | | `gwtls`| `git worktree list $args` | 133 | | `gwtmv`| `git worktree move $args` | 134 | | `gwtrm`| `git worktree remove $args` | 135 | -------------------------------------------------------------------------------- /src/aliases.ps1: -------------------------------------------------------------------------------- 1 | . $PSScriptRoot\utils.ps1 2 | 3 | # Prevent conflict with built-in aliases 4 | Remove-Alias gc -Force -ErrorAction SilentlyContinue 5 | Remove-Alias gcb -Force -ErrorAction SilentlyContinue 6 | Remove-Alias gcm -Force -ErrorAction SilentlyContinue 7 | Remove-Alias gcs -Force -ErrorAction SilentlyContinue 8 | Remove-Alias gl -Force -ErrorAction SilentlyContinue 9 | Remove-Alias gm -Force -ErrorAction SilentlyContinue 10 | Remove-Alias gp -Force -ErrorAction SilentlyContinue 11 | Remove-Alias gpv -Force -ErrorAction SilentlyContinue 12 | 13 | function g { 14 | git $args 15 | } 16 | function ga { 17 | git add $args 18 | } 19 | function gaa { 20 | git add --all $args 21 | } 22 | function gapa { 23 | git add --patch $args 24 | } 25 | function gau { 26 | git add --update $args 27 | } 28 | function gb { 29 | git branch $args 30 | } 31 | function gba { 32 | git branch -a $args 33 | } 34 | function gbd { 35 | git branch -d $args 36 | } 37 | function gbda { 38 | $MainBranch = Get-Git-MainBranch 39 | $MergedBranchs = $(git branch --merged | Select-String "^(\*|\s*($MainBranch|develop|dev)\s*$)" -NotMatch).Line 40 | $MergedBranchs | ForEach-Object { 41 | if ([string]::IsNullOrEmpty($_)) { 42 | return 43 | } 44 | git branch -d $_.Trim() 45 | } 46 | } 47 | function gbl { 48 | git blame -b -w $args 49 | } 50 | function gbnm { 51 | git branch --no-merged $args 52 | } 53 | function gbr { 54 | git branch --remote $args 55 | } 56 | function gbs { 57 | git bisect $args 58 | } 59 | function gbsb { 60 | git bisect bad $args 61 | } 62 | function gbsg { 63 | git bisect good $args 64 | } 65 | function gbsr { 66 | git bisect reset $args 67 | } 68 | function gbss { 69 | git bisect start $args 70 | } 71 | function gc { 72 | git commit -v $args 73 | } 74 | function gc! { 75 | git commit -v --amend $args 76 | } 77 | function gcn! { 78 | git commit -v --no-edit --amend $args 79 | } 80 | function gca { 81 | git commit -v -a $args 82 | } 83 | function gcam { 84 | git commit -a -m $args 85 | } 86 | function gca! { 87 | git commit -v -a --amend $args 88 | } 89 | function gcan! { 90 | git commit -v -a --no-edit --amend $args 91 | } 92 | function gcans! { 93 | git commit -v -a -s --no-edit --amend $args 94 | } 95 | function gcb { 96 | git checkout -b $args 97 | } 98 | function gcf { 99 | git config --list $args 100 | } 101 | function gcl { 102 | git clone --recursive $args 103 | } 104 | function gclean { 105 | git clean -df $args 106 | } 107 | function gcm { 108 | $MainBranch = Get-Git-MainBranch 109 | 110 | git checkout $MainBranch $args 111 | } 112 | function gcd { 113 | git checkout develop $args 114 | } 115 | function gcmsg { 116 | git commit -m $args 117 | } 118 | function gco { 119 | git checkout $args 120 | } 121 | function gcount { 122 | git shortlog -sn $args 123 | } 124 | function gcp { 125 | git cherry-pick $args 126 | } 127 | function gcpa { 128 | git cherry-pick --abort $args 129 | } 130 | function gcpc { 131 | git cherry-pick --continue $args 132 | } 133 | function gcs { 134 | git commit -S $args 135 | } 136 | function gd { 137 | git diff $args 138 | } 139 | function gds { 140 | git diff --staged $args 141 | } 142 | function gdca { 143 | git diff --cached $args 144 | } 145 | function gdt { 146 | git diff-tree --no-commit-id --name-only -r $args 147 | } 148 | function gdw { 149 | git diff --word-diff $args 150 | } 151 | function gf { 152 | git fetch $args 153 | } 154 | function gfa { 155 | git fetch --all --prune $args 156 | } 157 | function gfo { 158 | git fetch origin $args 159 | } 160 | function gg { 161 | git gui citool $args 162 | } 163 | function gga { 164 | git gui citool --amend $args 165 | } 166 | function ggf { 167 | $CurrentBranch = Get-Git-CurrentBranch 168 | 169 | git push --force origin $CurrentBranch 170 | } 171 | function ggfl { 172 | $CurrentBranch = Get-Git-CurrentBranch 173 | 174 | git push --force-with-lease origin $CurrentBranch 175 | } 176 | function ghh { 177 | git help $args 178 | } 179 | function ggsup { 180 | $CurrentBranch = Get-Git-CurrentBranch 181 | 182 | git branch --set-upstream-to=origin/$CurrentBranch 183 | } 184 | function gpsup { 185 | $CurrentBranch = Get-Git-CurrentBranch 186 | 187 | git push --set-upstream origin $CurrentBranch 188 | } 189 | function gignore { 190 | git update-index --assume-unchanged $args 191 | } 192 | function gignored { 193 | git ls-files -v | Select-String "^[a-z]" -CaseSensitive 194 | } 195 | function gl { 196 | git pull $args 197 | } 198 | function glg { 199 | git log --stat --color $args 200 | } 201 | function glgg { 202 | git log --graph --color $args 203 | } 204 | function glgga { 205 | git log --graph --decorate --all $args 206 | } 207 | function glgm { 208 | git log --graph --max-count=10 $args 209 | } 210 | function glgp { 211 | git log --stat --color -p $args 212 | } 213 | function glo { 214 | git log --oneline --decorate --color $args 215 | } 216 | function glog { 217 | git log --oneline --decorate --color --graph $args 218 | } 219 | function gloga { 220 | git log --oneline --decorate --color --graph --all $args 221 | } 222 | function glol { 223 | git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit $args 224 | } 225 | function glola { 226 | git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --all $args 227 | } 228 | function gm { 229 | git merge $args 230 | } 231 | function gmom { 232 | $MainBranch = Get-Git-MainBranch 233 | 234 | git merge origin/$MainBranch $args 235 | } 236 | function gmt { 237 | git mergetool --no-prompt $args 238 | } 239 | function gmtvim { 240 | git mergetool --no-prompt --tool=vimdiff $args 241 | } 242 | function gmum { 243 | $MainBranch = Get-Git-MainBranch 244 | 245 | git merge upstream/$MainBranch $args 246 | } 247 | function gp { 248 | git push $args 249 | } 250 | function gpd { 251 | git push --dry-run $args 252 | } 253 | function gpf { 254 | git push --force-with-lease $args 255 | } 256 | function gpf! { 257 | git push --force $args 258 | } 259 | function gpoat { 260 | git push origin --all 261 | git push origin --tags 262 | } 263 | function gpr { 264 | git pull --rebase $args 265 | } 266 | function gpra { 267 | git pull --rebase --autostash $args 268 | } 269 | function gpristine { 270 | git reset --hard 271 | git clean -dfx 272 | } 273 | function gprv { 274 | git pull --rebase -v $args 275 | } 276 | function gpu { 277 | git push upstream $args 278 | } 279 | function gpv { 280 | git push -v $args 281 | } 282 | function gr { 283 | git remote $args 284 | } 285 | function gra { 286 | git remote add $args 287 | } 288 | function grb { 289 | git rebase $args 290 | } 291 | function grba { 292 | git rebase --abort $args 293 | } 294 | function grbc { 295 | git rebase --continue $args 296 | } 297 | function grbi { 298 | git rebase -i $args 299 | } 300 | function grbm { 301 | $MainBranch = Get-Git-MainBranch 302 | 303 | git rebase $MainBranch $args 304 | } 305 | function grbs { 306 | git rebase --skip $args 307 | } 308 | function grh { 309 | git reset $args 310 | } 311 | function grhh { 312 | git reset --hard $args 313 | } 314 | function grmv { 315 | git remote rename $args 316 | } 317 | function groh { 318 | $CurrentBranch = Get-Git-CurrentBranch 319 | 320 | git reset origin/$CurrentBranch --hard 321 | } 322 | function grrm { 323 | git remote remove $args 324 | } 325 | function grs { 326 | git restore $args 327 | } 328 | function grst { 329 | git restore --staged $args 330 | } 331 | function grset { 332 | git remote set-url $args 333 | } 334 | function grt { 335 | try { 336 | $RootPath = git rev-parse --show-toplevel 337 | } 338 | catch { 339 | $RootPath = "." 340 | } 341 | Set-Location $RootPath 342 | } 343 | function gru { 344 | git reset -- $args 345 | } 346 | function grup { 347 | git remote update $args 348 | } 349 | function grv { 350 | git remote -v $args 351 | } 352 | function gsb { 353 | git status -sb $args 354 | } 355 | function gsd { 356 | git svn dcommit $args 357 | } 358 | function gsh { 359 | git show $args 360 | } 361 | function gsi { 362 | git submodule init $args 363 | } 364 | function gsps { 365 | git show --pretty=short --show-signature $args 366 | } 367 | function gsr { 368 | git svn rebase $args 369 | } 370 | function gss { 371 | git status -s $args 372 | } 373 | function gst { 374 | git status $args 375 | } 376 | function gsta { 377 | git stash save $args 378 | } 379 | function gstaa { 380 | git stash apply $args 381 | } 382 | function gstd { 383 | git stash drop $args 384 | } 385 | function gstl { 386 | git stash list $args 387 | } 388 | function gstp { 389 | git stash pop $args 390 | } 391 | function gstc { 392 | git stash clear $args 393 | } 394 | function gsts { 395 | git stash show --text $args 396 | } 397 | function gsu { 398 | git submodule update $args 399 | } 400 | function gsw { 401 | git switch $args 402 | } 403 | function gswc { 404 | git switch --create $args 405 | } 406 | function gts { 407 | git tag -s $args 408 | } 409 | function gunignore { 410 | git update-index --no-assume-unchanged $args 411 | } 412 | function gunwip { 413 | Write-Output $(git log -n 1 | Select-String "--wip--" -Quiet).Count 414 | git reset HEAD~1 415 | } 416 | function gup { 417 | Write-Host-Deprecated "gup" "gpr" 418 | git pull --rebase $args 419 | } 420 | function gupa { 421 | Write-Host-Deprecated "gupa" "gpra" 422 | git pull --rebase --autostash $args 423 | } 424 | function gupv { 425 | Write-Host-Deprecated "gupv" "gprv" 426 | git pull --rebase -v $args 427 | } 428 | function glum { 429 | $MainBranch = Get-Git-MainBranch 430 | 431 | git pull upstream $MainBranch $args 432 | } 433 | function gvt { 434 | git verify-tag $args 435 | } 436 | function gwch { 437 | git whatchanged -p --abbrev-commit --pretty=medium $args 438 | } 439 | function gwip { 440 | git add -A 441 | git rm $(git ls-files --deleted) 2> $null 442 | git commit --no-verify -m "--wip-- [skip ci]" 443 | } 444 | function ggl { 445 | $CurrentBranch = Get-Git-CurrentBranch 446 | 447 | git pull origin $CurrentBranch 448 | } 449 | function ggp { 450 | $CurrentBranch = Get-Git-CurrentBranch 451 | 452 | git push origin $CurrentBranch 453 | } 454 | function ggpnp { 455 | ggl; ggp $args 456 | } 457 | function gprom { 458 | $MainBranch = Get-Git-MainBranch 459 | 460 | git pull --rebase origin $MainBranch $args 461 | } 462 | function gwt { 463 | git worktree $args 464 | } 465 | function gwta { 466 | git worktree add $args 467 | } 468 | function gwtls { 469 | git worktree list $args 470 | } 471 | function gwtmv { 472 | git worktree move $args 473 | } 474 | function gwtrm { 475 | git worktree remove $args 476 | } 477 | --------------------------------------------------------------------------------