Created
April 8, 2019 13:55
-
-
Save urbanit/2af4b7d753a24c4a986221352e9e36e9 to your computer and use it in GitHub Desktop.
Git Fork
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
param([string]$repo, # repo name | |
[string]$remote="urbanit", # your user name | |
[string]$upstream="RFAssurance", # project admin user name | |
[string]$branch="dev") # default branch | |
$ElapsedTime = [System.Diagnostics.Stopwatch]::StartNew() | |
if (-Not ($repo)) | |
{ | |
Throw "You must specify an repo name" | |
} | |
Write-Host "Repo: $repo" -foregroundcolor "magenta" | |
$basePath = "c:\Projects\" | |
$path = $basePath + $repo + "\" + $remote | |
If(!(test-path $path)) | |
{ | |
New-Item -ItemType Directory -Force -Path $path | |
Write-Host "Path: $path created" -foregroundcolor "green" | |
}Else{ | |
Write-Host "Path: $path exist" -foregroundcolor "red" | |
} | |
Set-Location $path | |
git clone https://github.com/$remote/$repo.git 2>$null # in order to avoid stder | |
Write-Host "Repo: $repo cloned" -foregroundcolor "green" | |
Set-Location ($path + "\" + $repo) | |
git remote add upstream https://github.com/$upstream/$repo.git 2>$null | |
git fetch upstream 2>$null | |
git checkout $branch 2>$null | |
git merge upstream/$branch 2>$null | |
Write-Host "Repo: $repo synced" -foregroundcolor "green" | |
Write-Host $ElapsedTime.Elapsed.ToString() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment