Get-GitRepositoryStatus

Gets information about all added, untracked, and modified files in a repository.

Syntax

Get-GitRepositoryStatus [[-Path] <String[]>] [-IncludeIgnored] [-RepoRoot <String>] [<CommonParameters>]

Description

The Get-GitRepositoryStatus commands gets information about which files in your working directory are new, untracked, or modified, including files that have been staged for the next commit. It gets information about each uncommitted change in your repository.

Ignored items are not returned unless you provide the IncludeIgnored switch.

You can get status for specific files and directories with the Path parameter. If you provide a RepoRoot parameter to work with a specific repository, the values of the Path parameter should be relative to the root of that repository. With no RepoRoot parameter, the paths in the Path parameter are treated as relative to the current directory. Wildcards are supported and are passed directly to Git to evaluate (i.e. use Git wildcard syntax not PowerShell's).

The LibGit2Sharp.StatusEntry objects returned have several extended type data members added. You should use these members instead of using the object's State property.

When displayed in a table (the default), the first column will show characters that indicate the state of each item, e.g.

State    FilePath                                                                                                                                                                                                                                            
-----    --------                                                                                                                                                                                                                                            
 a       LibGit2\Formats\LibGit2Sharp.StatusEntry.ps1xml                                                                                                                                                                                                     
 a       LibGit2\Functions\Get-GitRepositoryStatus.ps1                                                                                                                                                                                                       
  m      LibGit2\LibGit2.psd1                                                                                                                                                                                                                                
 a       LibGit2\Types\LibGit2Sharp.StatusEntry.types.ps1xml                                                                                                                                                                                                 
 a       Tests\Get-GitRepositoryStatus.Tests.ps1

The state will display:

If no state characters are shown, the file is unchanged (i.e. IsUnchanged return $true).

This function implements the git status command.

Parameters

Name Type Description Required? Pipeline Input Default Value
Path String[]

The path to specific files and/or directories whose status to get. Git-style wildcards are supported.

If no RepoRoot parameter is provided, these paths are evaluated as relative to the current directory. If a RepoRoot parameter is provided, these paths are evaluated as relative to the root of that repository.

false false
IncludeIgnored SwitchParameter

Return ignored files and directories. The default is to not return them.

false false False
RepoRoot String

The path to the repository whose status to get.

false false (Get-Location).ProviderPath

Return Values

LibGit2Sharp.StatusEntry.

EXAMPLE 1

Get-GitRepositoryStatus

Demonstrates how to get the status of any uncommitted changes for the repository in the current directory.

EXAMPLE 2

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

Demonstrates how to get the status of any uncommitted changes for the repository at a specific location.

EXAMPLE 3

Get-GitRepositoryStatus -Path 'build.ps1','*.cs'

Demonstrates how to get the status for specific files at or under the current directory using the Path parameter. In this case, only modified files named build.ps1 or that match the wildcard *.cs under the current directory will be returned.

EXAMPLE 4

Get-GitRepositoryStatus -Path 'build.ps1','*.cs' -RepoRoot 'C:\Projects\LibGit2.PowerShell`

Demonstrates how to get the status for specific files under the root of a specific repository. In this case, only modified files named build.ps1 or that match the wildcard *.cs under C:\Projects\LibGit2.PowerShell will be returned.