Auf nach Git mit dem Krempel!
This commit is contained in:
53
push-updates.ps1
Normal file
53
push-updates.ps1
Normal file
@@ -0,0 +1,53 @@
|
||||
# Ein super dummes PowerShell Script.
|
||||
# Für mich:
|
||||
# Nutzung ist easy.
|
||||
# Erst git init in dem Ordner
|
||||
# Dann git branch -M mai
|
||||
# Dann git add . und git commit -m "Nachricht!"
|
||||
# Leeres(!) Gitea Repo erstellen
|
||||
# git remote add origin [Link hier]
|
||||
# Und dann nur noch dieses Script im Verzeichnis des Repo lokal ausführen und es pusht automatisch Änderungen hoch.
|
||||
|
||||
# push-updates.ps1
|
||||
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
Write-Host "Working in $(Get-Location)"
|
||||
|
||||
# Prüfen ob Git-Repo
|
||||
if (-not (Test-Path ".git")) {
|
||||
Write-Host "Kein Git-Repository im aktuellen Ordner."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Optional: Pull mit Rebase
|
||||
try {
|
||||
git pull --rebase | Out-Null
|
||||
}
|
||||
catch {
|
||||
Write-Host "Pull fehlgeschlagen – evtl. Konflikt. Abbruch."
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Änderungen hinzufügen
|
||||
git add -A | Out-Null
|
||||
|
||||
# Prüfen ob Änderungen existieren
|
||||
$changes = git status --porcelain
|
||||
|
||||
if ([string]::IsNullOrWhiteSpace($changes)) {
|
||||
Write-Host "Keine Änderungen – nichts zu committen."
|
||||
exit 0
|
||||
}
|
||||
|
||||
# Commit
|
||||
$stamp = Get-Date -Format "yyyy-MM-dd HH:mm"
|
||||
$msg = "Auto-Commit $stamp"
|
||||
|
||||
git commit -m $msg | Out-Null
|
||||
|
||||
# Push
|
||||
git push | Out-Null
|
||||
|
||||
Write-Host "Push erfolgreich: $msg"
|
||||
Reference in New Issue
Block a user