File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments