Get-GitRepository

Gets an object representing a Git repository.

Syntax

Get-GitRepository [[-RepoRoot] <String>] [<CommonParameters>]

Description

The Get-GitRepository function gets a LibGit2Sharp.Repository object representing a Git repository. By default, it gets the current directory's repository. You can get an object for a specific repository using the RepoRoot parameter. If the RepoRoot path doesn't point to the root of a Git repository, or, if not using the RepoRoot parameter and the current directory isn't the root of a Git repository, you'll get an error.

The repository object contains resources that don't get automatically removed from memory by .NET. To avoid memory leaks, you must call its Dispose() method when you're done using it.

Parameters

Name Type Description Required? Pipeline Input Default Value
RepoRoot String

The root to the repository to get. Defaults to the current directory.

false false (Get-Location).ProviderPath

Return Values

LibGit2Sharp.Repository.

EXAMPLE 1

Get-GitRepository

Demonstrates how to get a LibGit2Sharp.Repository object for the repository in the current directory.

EXAMPLE 2

Get-GitRepository -RepoRoot 'C:\Projects\LibGit2.PowerShell'

Demonstrates how to get a LibGit2Sharp.Repository object for a specific repository.