Skip to content

Commit 6f00b0a

Browse files
author
Markus Fleschutz
committed
Added clone-shallow.ps1
1 parent 5294594 commit 6f00b0a

1 file changed

Lines changed: 32 additions & 0 deletions

File tree

scripts/clone-shallow.ps1

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<#
2+
.SYNOPSIS
3+
Clones a shallow Git repo
4+
.DESCRIPTION
5+
This PowerShell script clones popular Git repositories into a common target directory.
6+
.PARAMETER URL
7+
.PARAMETER branchName
8+
.PARAMETER targetDir
9+
Specifies the file path to the target directory (current working directory by default)
10+
.EXAMPLE
11+
PS> ./clone-shallow C:\MyRepos
12+
.LINK
13+
https://github.com/fleschutz/PowerShell
14+
.NOTES
15+
Author: Markus Fleschutz | License: CC0
16+
#>
17+
18+
param([string]$targetDir = "$PWD")
19+
20+
try {
21+
$stopWatch = [system.diagnostics.stopwatch]::startNew()
22+
23+
$ git clone --branch $branchName --single-branch --depth 1 --recurse-submodules $URL $targetDir
24+
25+
26+
[int]$elapsed = $stopWatch.Elapsed.TotalSeconds
27+
"✔️ Cloned the shallow repository in $elapsed sec"
28+
exit 0 # success
29+
} catch {
30+
"⚠️ Error in line $($_.InvocationInfo.ScriptLineNumber): $($Error[0])"
31+
exit 1
32+
}

0 commit comments

Comments
 (0)