Clones a git repository.
Invoke-GitClone [-RepoURL] <String> [[-ParentDir] <String>] [[-RepoName] <String>] [-AppendPowdrgitPath]
[-SetLocation] [-WhatIf] [-Confirm] [<CommonParameters>]
Invoke-GitClone [-RepoURL] <String> [[-RepoName] <String>] [-UseDefaultDir] [-AppendPowdrgitPath]
[-SetLocation] [-WhatIf] [-Confirm] [<CommonParameters>]
Clones a git repository to the specified directory.
## Clone a non-existent repository from a URL ##
PS C:\> $Powdrgit.ShowWarnings = $true # to ensure warnings are visible
PS C:\> Invoke-GitClone -RepoURL 'https://my.repos.com/MyMissingRepo'
WARNING: [Invoke-GitClone]fatal: repository 'https://my.repos.com/MyMissingRepo/' not found
# Attempting to clone to a non-existent repository generates a warning.
## Clone an existent repository from a URL ##
PS C:\> Invoke-GitClone -RepoURL 'https://my.repos.com/MyToolbox' | Format-Table Name,FullName
Name FullName
---- --------
MyToolbox C:\MyToolbox
# The repository was cloned to the current directory.
## Clone a repository from a local path ##
PS C:\> Invoke-GitClone -RepoURL 'C:\PowdrgitExamples\MyToolbox' | Format-Table Name,FullName
Name FullName
---- --------
MyToolbox C:\MyToolbox
# The repository was cloned to the current directory.
## Clone a repository to an existing repository ##
PS C:\> $Powdrgit.ShowWarnings = $true # to ensure warnings are visible
PS C:\> Invoke-GitClone -RepoURL 'C:\PowdrgitExamples\MyToolbox'
WARNING: [Invoke-GitClone]fatal: destination path 'C:\MyToolbox' already exists and is not an empty directory.
# Attempting to clone to an existing repository generates a warning.
## Clone a repository with $Powdrgit.DefaultCloneUrl set ##
PS C:\> $Powdrgit.DefaultCloneUrl = 'C:\PowdrgitExamples\\\<RepoURL>'
PS C:\> Invoke-GitClone -RepoURL 'MyToolbox' | Format-Table Name,FullName
Name FullName
---- --------
MyToolbox C:\MyToolbox
# Equivalent to the previous example
## Clone a repository to a specified directory ##
PS C:\> Invoke-GitClone -RepoURL 'C:\PowdrgitExamples\MyToolbox' -ParentDir 'C:\Temp' | Format-Table Name,FullName
Name FullName
---- --------
MyToolbox C:\Temp\MyToolbox
# The repository was cloned to the specified directory.
## Clone a repository with a specified name ##
PS C:\> Invoke-GitClone -RepoURL 'C:\PowdrgitExamples\MyToolbox' -RepoName 'MyTools' | Format-Table Name,FullName
Name FullName
---- --------
MyTools C:\MyTools
# The repository was cloned to the specified directory and given the specified name.
## Clone a repository to the default directory ##
PS C:\> $Powdrgit.DefaultDir = 'C:\Temp'
PS C:\> Invoke-GitClone -RepoURL 'C:\PowdrgitExamples\MyToolbox' -UseDefaultDir | Format-Table Name,FullName
Name FullName
---- --------
MyToolbox C:\Temp\MyToolbox
# The repository was cloned to the default directory.
## Clone a repository and add the path to $Powdrgit.Path ##
PS C:\> $Powdrgit.Path = 'C:\PowdrgitExamples\Project1'
PS C:\> Invoke-GitClone -RepoURL 'C:\PowdrgitExamples\MyToolbox' -AppendPowdrgitPath | Out-Null
PS C:\> Test-PowdrgitPath -PassThru
C:\MyToolbox
C:\PowdrgitExamples\Project1
# A [GitRepo] object is returned and the repository path is added to the $Powdrgit.Path module variable.
## Clone a repository and set the location to the repository ##
PS C:\> Invoke-GitClone -RepoURL 'C:\PowdrgitExamples\MyToolbox' -SetLocation | Out-Null
PS C:\MyToolbox>
# The location was changed to the repository top-level folder.
Appends the path of the cloned repository to the $Powdrgit.Path module variable.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
The parent directory where the git repository will be cloned to. If the parameter is omitted, and a default parent directory is defined in $Powdrgit.DefaultDir, the repository will be cloned under that directory. If no directory is specified, the repository is cloned to the current location.
Type: String
Parameter Sets: ParentDir
Aliases: FullName, Path
Required: False
Position: 2
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
The name to give the repository (the folder name of the top-level directory of the cloned repository). If the parameter is omitted, the name will be derived from the RepoURL value.
Type: String
Parameter Sets: (All)
Aliases:
Required: False
Position: 3
Default value: None
Accept pipeline input: True (ByPropertyName)
Accept wildcard characters: False
The URL of the git repository to clone. If a default URL root is defined in $Powdrgit.DefaultCloneUrl, only the repository name is required. The URL can start with any of the following: http://, https://, ftp://, ftps://, git://, ssh://, [A-Z]:\, \\
Type: String
Parameter Sets: (All)
Aliases:
Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByPropertyName, ByValue)
Accept wildcard characters: False
Sets the location to the top-level directory of the cloned repository.
Type: SwitchParameter
Parameter Sets: (All)
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Uses the directory stored in the $Powdrgit.DefaultDir variable as the ParentDir value.
Type: SwitchParameter
Parameter Sets: UseDefaultDir
Aliases:
Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
Prompts you for confirmation before running the cmdlet.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: cf
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: SwitchParameter
Parameter Sets: (All)
Aliases: wi
Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.
[System.String]
Accepts string objects via the RepoURL parameter.
[GitRepo]
[System.IO.DirectoryInfo]
Returns either a custom GitRepo object or a System.IO.DirectoryInfo object.
The DirectoryInfo property of the GitRepo object contains the System.IO.DirectoryInfo object for the repository.
Author : nmbell