Skip to content

Instantly share code, notes, and snippets.

@warm-ice0x00
Last active August 18, 2021 02:43
Show Gist options
  • Save warm-ice0x00/4d63513b7f84bc1d673ce92324378cff to your computer and use it in GitHub Desktop.
Save warm-ice0x00/4d63513b7f84bc1d673ce92324378cff to your computer and use it in GitHub Desktop.
Universal Git Script (PowerShell Version)
[CmdletBinding()] param([Parameter(Mandatory = $true)] [string]$Url)
$dotGitPath = Join-Path -Path $PWD -ChildPath .git
Remove-Item -LiteralPath $dotGitPath -Force -Recurse -ErrorAction SilentlyContinue
& git init
& git remote add origin $Url
& git add -A
& git reset $MyInvocation.MyCommand.Definition
& git commit -am 'Initial commit'
& git push -f origin master
Remove-Item -LiteralPath $dotGitPath -Force -Recurse
Write-Output -InputObject 'Done! If there is a problem, rerun the script.'
#Inspired by xkcd: Git https://xkcd.com/1597/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment