Make git extensible like it is on any non-windows OS with your own (powershell) scripts. You can achieve the same without this module but it can save you time and headaches.
PsGitScript is a simple powershell module that scans your directories (from PATH env. variable) for potential git extensions git-<alias>.ps1. The extension scripts will be added to the .gitconfig file as an alias. After that you can invoke them like git <alias>.
PsGitScript will update aliases on every powershell launch, but never deletes anything from .gitconfig file.
-
Powershell (tested on Powershell 7)
-
Enable script execution. Set-ExecutionPolicy
-
Git for Windows (tested on git version 2.34.1.windows.1)
Open powershell 7 and execute the following command:
Install-Module -Name PsGitScriptEdit the Profile.ps1 file and add the following line:
Import-Module PsGitScriptCreate a script git-test.ps1 in a folder that is included in $Path variable, with the following content:
Write-Host "Hello, World!"You can check
$Pathvariable in powershell with the following command:$Env:Path -Split ';'
You just created a new script what needs to be registered in .gitconfig file as an alias.
You can restart your pwsh session or execute the Invoke-PsGitScriptInit command to update the aliases.
Now you can call your script:
git helloPlease note that every git script runs in a new pwsh session with no profile and bypass execution policy.
Creating an initializer script for your custom git scripts is strongly recommended.