Last active
August 13, 2021 13:28
-
-
Save sannae/cc21a56d261fbcc58d8e6bd63874976a to your computer and use it in GitHub Desktop.
One-liner to add, commit and push to remote Git
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
function New-GitCommit { | |
[cmdletbinding()] | |
param( | |
[Parameter(Mandatory=$true)] | |
[string]$CommitMessage | |
) | |
Write-Host "Git - Adding all changes..." -ForeGroundColor Green | |
git add --all | |
Write-Host "Git - Committing with provided message..." -ForeGroundColor Green | |
git commit -m $CommitMessage | Tee-Object -Variable GitCommit | |
Write-Host $GitCOmmit | |
if ( -Not ("nothing to commit, working tree clean" -in $GitCommit) ) { | |
Write-Host "Git - Pushing to remote origin..." -ForeGroundColor Green | |
git push | |
} | |
} | |
Set-Alias -Name "ngc" -Value "New-GitCommit" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment