Exporting the Contents of a Git Repository with PowerShell
Wednesday, April 23, 2014 at 6:37PM
saveenr

A handy script for automating quickly getting the code out of a git repo, without actually wanting all the history of the repo.

$GITEXE="C:\Program Files (x86)\Git\bin\git.exe"
$REPO="https://github.com/advancedrei/MetaWeblogPortable.git"
$DESTDIR="d:\SourceCodeExport"

# Clean out destination folder
if (Test-Path $DESTDIR)
{
    Remove-Item -Recurse -Force $DESTDIR
}

# Clone from repo to folder
&$GITEXE clone --depth 1 $REPO $DESTDIR

# Remove non-source code files from the destination folder
Remove-Item -Recurse -Force ( join-path $DESTDIR ".git")

In my case, I needed to ZIP up the contents also. If you need to do check out this post: how to create ZIPs easily with PowerShell.

Article originally appeared on viziblr (http://viziblr.com/).
See website for complete article licensing information.