-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpush-to-github.ps1
More file actions
107 lines (87 loc) · 3.4 KB
/
Copy pathpush-to-github.ps1
File metadata and controls
107 lines (87 loc) · 3.4 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# GitHub Push Script for ExporTrack-AI
# Run this script in PowerShell to push your changes to GitHub
Write-Host "========================================" -ForegroundColor Cyan
Write-Host " ExporTrack-AI GitHub Push Script" -ForegroundColor Cyan
Write-Host "========================================" -ForegroundColor Cyan
Write-Host ""
# Check if git is available
$gitVersion = git --version 2>$null
if (-not $gitVersion) {
Write-Host "Error: Git is not installed or not in PATH" -ForegroundColor Red
exit 1
}
Write-Host "Git version: $gitVersion" -ForegroundColor Green
# Check if we're in a git repository
$isGitRepo = git rev-parse --git-dir 2>$null
if (-not $isGitRepo) {
Write-Host "Error: Not a git repository. Please initialize git first." -ForegroundColor Red
exit 1
}
Write-Host ""
# Show current status
Write-Host "Checking git status..." -ForegroundColor Yellow
git status --short
Write-Host ""
# Ask for commit message
$commitMessage = Read-Host "Enter commit message (or press Enter for default)"
if ([string]::IsNullOrWhiteSpace($commitMessage)) {
$commitMessage = "fix: Improve authentication system (Login + Signup UI & Security)"
}
Write-Host ""
# Add all changes
Write-Host "Adding changes to staging..." -ForegroundColor Yellow
git add -A
Write-Host ""
# Show what will be committed
Write-Host "Files to be committed:" -ForegroundColor Cyan
git diff --cached --name-only
Write-Host ""
# Commit
Write-Host "Committing changes..." -ForegroundColor Yellow
git commit -m "$commitMessage"
if ($LASTEXITCODE -ne 0) {
Write-Host "Error: Failed to commit changes" -ForegroundColor Red
exit 1
}
Write-Host ""
Write-Host "Changes committed successfully!" -ForegroundColor Green
Write-Host ""
# Push to remote
$remote = git remote
if ([string]::IsNullOrWhiteSpace($remote)) {
Write-Host "Warning: No remote configured. To push to GitHub, add a remote:" -ForegroundColor Yellow
Write-Host " git remote add origin https://github.com/YOUR_USERNAME/YOUR_REPO.git" -ForegroundColor Cyan
Write-Host ""
$addRemote = Read-Host "Would you like to add a remote now? (y/n)"
if ($addRemote -eq "y" -or $addRemote -eq "Y") {
$repoUrl = Read-Host "Enter your GitHub repository URL"
git remote add origin $repoUrl
} else {
Write-Host "Skipping push. Run 'git push' manually when ready." -ForegroundColor Yellow
exit 0
}
}
Write-Host ""
Write-Host "Pushing to GitHub..." -ForegroundColor Yellow
git push -u origin main
if ($LASTEXITCODE -eq 0) {
Write-Host ""
Write-Host "========================================" -ForegroundColor Green
Write-Host " Successfully pushed to GitHub!" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Green
} else {
# Try alternative branch names
Write-Host "Trying with 'master' branch..." -ForegroundColor Yellow
git push -u origin master
if ($LASTEXITCODE -eq 0) {
Write-Host ""
Write-Host "========================================" -ForegroundColor Green
Write-Host " Successfully pushed to GitHub!" -ForegroundColor Green
Write-Host "========================================" -ForegroundColor Green
} else {
Write-Host ""
Write-Host "Error: Failed to push to GitHub" -ForegroundColor Red
Write-Host "Please check your remote URL and authentication" -ForegroundColor Yellow
exit 1
}
}