mirror of
https://github.com/fleschutz/PowerShell.git
synced 2024-11-25 17:33:17 +01:00
78 lines
1.9 KiB
Markdown
78 lines
1.9 KiB
Markdown
|
Script: *clone-shallow.ps1*
|
||
|
========================
|
||
|
|
||
|
This PowerShell script clones popular Git repositories into a common target directory.
|
||
|
|
||
|
Parameters
|
||
|
----------
|
||
|
```powershell
|
||
|
PS> ./clone-shallow.ps1 [[-targetDir] <String>] [<CommonParameters>]
|
||
|
|
||
|
-targetDir <String>
|
||
|
Specifies the file path to the target directory (current working directory by default)
|
||
|
|
||
|
Required? false
|
||
|
Position? 1
|
||
|
Default value "$PWD"
|
||
|
Accept pipeline input? false
|
||
|
Accept wildcard characters? false
|
||
|
|
||
|
[<CommonParameters>]
|
||
|
This script supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction,
|
||
|
WarningVariable, OutBuffer, PipelineVariable, and OutVariable.
|
||
|
```
|
||
|
|
||
|
Example
|
||
|
-------
|
||
|
```powershell
|
||
|
PS> ./clone-shallow C:\MyRepos
|
||
|
|
||
|
```
|
||
|
|
||
|
Notes
|
||
|
-----
|
||
|
Author: Markus Fleschutz | License: CC0
|
||
|
|
||
|
Related Links
|
||
|
-------------
|
||
|
https://github.com/fleschutz/PowerShell
|
||
|
|
||
|
Script Content
|
||
|
--------------
|
||
|
```powershell
|
||
|
<#
|
||
|
.SYNOPSIS
|
||
|
Clones a shallow Git repo
|
||
|
.DESCRIPTION
|
||
|
This PowerShell script clones popular Git repositories into a common target directory.
|
||
|
.PARAMETER URL
|
||
|
.PARAMETER branchName
|
||
|
.PARAMETER targetDir
|
||
|
Specifies the file path to the target directory (current working directory by default)
|
||
|
.EXAMPLE
|
||
|
PS> ./clone-shallow C:\MyRepos
|
||
|
.LINK
|
||
|
https://github.com/fleschutz/PowerShell
|
||
|
.NOTES
|
||
|
Author: Markus Fleschutz | License: CC0
|
||
|
#>
|
||
|
|
||
|
param([string]$targetDir = "$PWD")
|
||
|
|
||
|
try {
|
||
|
$stopWatch = [system.diagnostics.stopwatch]::startNew()
|
||
|
|
||
|
$ git clone --branch $branchName --single-branch --depth 1 --recurse-submodules $URL $targetDir
|
||
|
|
||
|
|
||
|
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
|
||
|
"✔️ Cloned the shallow repository in $elapsed sec"
|
||
|
exit 0 # success
|
||
|
} catch {
|
||
|
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
|
||
|
exit 1
|
||
|
}
|
||
|
```
|
||
|
|
||
|
*(generated by convert-ps2md.ps1 using the comment-based help of clone-shallow.ps1 as of 08/15/2024 09:50:46)*
|