PowerShell Helper scripts to manage git repositories.
- Copy the files
- Open Command Line or PowerShell (Window + X, A)
- If you opened Command Prompt, then type powershell in order to use PowerShell commands
- Navigate to the scripts directory
cd your_directory - Type
Import-Module .\GitHelper.psm1 - Now you can use the methods from your PowerShell session
- Enable execution policy using PowerShell Admin
Set-ExecutionPolicy Unrestricted - Navigate to the profile path
cd (Split-Path -parent $PROFILE) - Open the location in Explorer
ii . - Create the user profile if it does not exist
If (!(Test-Path -Path $PROFILE )) { New-Item -Type File -Path $PROFILE -Force } - Import the module in the PowerShell profile
Import-Module -Path script_directory -ErrorAction SilentlyContinue
Prune Remote origin branches.
Prune remote origin branches
Clean-RemoteOrigin -Path 'C:\git\PowerShell\EnvironmentVariables\'
Prune remote origin branches for repository environment variable `Dev.Repository_***EnvironmentVariables***.Path`
Clean-RemoteOrigin -Repository 'EnvironmentVariables'
Performs a git pull for the current directory and its submodules. Also makes sure that none of the submodules are detached at a specific commit.
Pull Latest by path
Pull-Latest -Path "C:\git\PowerShell\EnvironmentVariables\"
Pull Latest by repository name
Pull-Latest -Repository 'EnvironmentVariables'
Clones the repositories that match the specified pattern.
Import all repositories defined as environment variables (pattern Dev.Repository_*.Name)
Import-Repositories
Import specific repository defined as environment variables
Import-Repositories -pattern "Dev.Repository_EnvironmentVariables.Name"
Clones repository by url and path and pulls latest files and submodules.
Clone repository to current directory
Clone-Repository -Url 'https://github.com/jhonnyelhelou91/EnvironmentVariables.git'
Clone repository to custom directory
Clone-Repository -Url 'https://github.com/jhonnyelhelou91/EnvironmentVariables.git' -Path 'C:\git\PowerShell\EnvironmentVariables\'