Skip to content

Instantly share code, notes, and snippets.

@DMeurer
Created December 12, 2024 14:42
Show Gist options
  • Save DMeurer/dcf36938362117d68cbf6de1c7b12fc9 to your computer and use it in GitHub Desktop.
Save DMeurer/dcf36938362117d68cbf6de1c7b12fc9 to your computer and use it in GitHub Desktop.
Auto-Backup a Git Repository. You can run it in Autostart or from TaskScheduler, etc. It will display MERGE CONFLICT and pause if you got one, otherwise it will just close itself. I'm using it to Backup a KeePass File.
git stash -u
git pull
git stash pop
$outp = $null;
$outp = git ls-files -u
if ($outp -eq $null){
Write-Host "No conflics" -ForegroundColor Green
} else {
Write-Host "===== MERGE CONFLICTS =====" -BackgroundColor DarkRed
pause
}
git add .
git commit -m "backup"
git push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment