Skip to content

jhonnyelhelou91/GitHelper

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

Git Helpers

PowerShell Helper scripts to manage git repositories.

Getting Started

  • 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

Adding Script to Profile [Optional]

  • 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

Examples

Clean-RemoteOrigin Example

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'

Pull-Latest Example

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'

Import-Repository Example

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"

Clone-Repository Example

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\'

About

PowerShell helper scripts to manage git repositories

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published