-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGitPull.ps1
68 lines (59 loc) · 2.04 KB
/
GitPull.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<#
Git commandline helpers for PowerShell
Author: Damian Suess
Revision: 1 - 2019-01-16
Usage:
GitPull ; Pulls current branch defaulting remote to "origin"
GitPull "NotOrigin" ; Pulls current branch from specified remote
GitPull -u ; Pull merging unrelated histories
TODO:
- Pulls branch and sets tracking so you can simply execute, ``git push`` next time
GitPull "NotOrigin" -track
- After pulling check for "fatal: refusing to merge unrelated histories" and suggest '-u' switch.
Change Log:
2019-01-16 0.1 - Created
#>
# Commandline Params ---
param(
[parameter(Mandatory=$false)][string] $remote = "origin",
[parameter(Mandatory=$false)][switch] $u = $false,
[Parameter(Mandatory=$false)][switch] $h = $false
# ,[parameter(Mandatory=$false)][switch] $track = $false
);
# Include Files --------
. "$PSScriptRoot/lib/GitHelpers.ps1";
# Our code -------------
if ($h -eq $true)
{
Write-Host "GitPull HELP";
Write-Host "-------------";
Write-Host "Pulls branch to remote repository" -ForegroundColor Yellow;
Write-Host " GitPull -remote <string> ; Pulls from specified remote (default: origin)" -ForegroundColor Yellow;
Write-Host " GitPull -u ; Pull merging unrelated histories" -ForegroundColor Yellow;
Write-Host " GitPull -h ; This help text" -ForegroundColor Yellow;
Write-Host "";
exit;
}
[string] $branchName = GitCurrentBranch;
if ($branchName.Trim() -eq "")
{
Write-Host "No repository found in currect directory." -ForegroundColor Red;
exit;
}
[string] $msg = "";
if ($u -eq $true)
{
$msg = " with unrelated history";
}
Write-Host "Pulling branch '${branchName}'${msg} from origin remote '${remote}'..." -ForegroundColor Green;
GitPull($remote)($branchName)($u);
# if ($track)
# {
# Write-Host "Pulling branch '${branchName}' with tracking..." -ForegroundColor Green;
# GitPull($remote)($branchName)($true)
# }
# else
# {
# Write-Host "Pulling branch '${branchName}'..." -ForegroundColor Green;
# GitPull($remote)($branchName)($false);
# }