-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgitcam.ps1
More file actions
35 lines (29 loc) · 708 Bytes
/
Copy pathgitcam.ps1
File metadata and controls
35 lines (29 loc) · 708 Bytes
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
<#
.SYNOPSIS
git amend commit changed files into recent commit
.PARAMETER ForcePush
Force push to remote
#>
param(
[switch]$Edit,
[switch]$ForcePush
)
$script:ErrorActionPreference = "Stop"
Set-StrictMode -Version Latest
$editArg = if ($Edit) { "--edit" } else { "--no-edit" }
$status = Get-GitStatus
$allArg = @()
if ($status.HasIndex) {
Write-Warning "Only staged files will be committed: $($status.Index -join " ")"
}
elseif ($status.HasUntracked) {
git status --porcelain | sls '^\?\?'
throw "Untracked files!"
} else {
Write-Verbose "Committing all files"
$allArg += "--all"
}
git commit --amend $editArg @allArg
if ($ForcePush) {
git push --force-with-lease --force-if-includes
}