Skip to content

Invoke‑Git

dscbot edited this page Oct 20, 2024 · 1 revision

SYNOPSIS

Invokes a git command.

SYNTAX

Invoke-Git [-WorkingDirectory] <String> [[-TimeOut] <Int32>] [-PassThru] [[-Arguments] <String[]>]
 [<CommonParameters>]

DESCRIPTION

Invokes a git command with command line arguments using System.Diagnostics.Process.

Throws an error when git ExitCode -ne 0 and -PassThru switch -eq $false (or omitted).

EXAMPLES

EXAMPLE 1

Invoke-Git -WorkingDirectory 'C:\SomeDirectory' -Arguments @( 'clone', 'https://github.com/X-Guardian/xActiveDirectory.wiki.git', '--quiet' )

Invokes the Git executable to clone the specified repository to the working directory.

EXAMPLE 2

Invoke-Git -WorkingDirectory 'C:\SomeDirectory' -Arguments @( 'status' ) -TimeOut 10000 -PassThru

Invokes the Git executable to return the status while having a 10000 millisecond timeout.

PARAMETERS

-Arguments

The arguments to pass to the Git executable.

Type: String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: 3
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-PassThru

Switch parameter when enabled will return result object of running git command.

Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False

-TimeOut

Milliseconds to wait for process to exit.

Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: 2
Default value: 120000
Accept pipeline input: False
Accept wildcard characters: False

-WorkingDirectory

The path to the git working directory.

Type: String
Parameter Sets: (All)
Aliases:

Required: True
Position: 1
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

INPUTS

OUTPUTS

System.Collections.Hashtable

NOTES

RELATED LINKS