-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauto-commit.ps1
More file actions
34 lines (26 loc) · 910 Bytes
/
auto-commit.ps1
File metadata and controls
34 lines (26 loc) · 910 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
# Auto-commit and push script for Git
$repoPath = "d:\Python Program"
$lastCommitTime = Get-Date
while ($true) {
cd $repoPath
# Check for changes
$status = git status --porcelain
if ($status) {
Write-Host "Changes detected at $(Get-Date)" -ForegroundColor Green
# Stage all changes
git add .
# Commit with timestamp
$timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
git commit -m "Auto-commit: $timestamp"
# Push to GitHub (both master and main)
git push origin master
git push origin main
git push --all
Write-Host "Committed and pushed successfully" -ForegroundColor Green
}
else {
Write-Host "No changes detected at $(Get-Date)" -ForegroundColor Yellow
}
# Wait 5 minutes before checking again
Start-Sleep -Seconds 300
}