This repository was archived by the owner on Feb 23, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgit_commit.ps1
More file actions
73 lines (59 loc) · 3.47 KB
/
git_commit.ps1
File metadata and controls
73 lines (59 loc) · 3.47 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
Write-Host "
███████╗██╗ ██╗████████╗██╗ ██╗██████╗ ███████╗ ██╗███╗ ██╗███████╗██╗ ██████╗ ██╗ ██╗████████╗
██╔════╝██║ ██║╚══██╔══╝██║ ██║██╔══██╗██╔════╝ ██║████╗ ██║██╔════╝██║██╔════╝ ██║ ██║╚══██╔══╝
█████╗ ██║ ██║ ██║ ██║ ██║██████╔╝█████╗ ██║██╔██╗ ██║███████╗██║██║ ███╗███████║ ██║
██╔══╝ ██║ ██║ ██║ ██║ ██║██╔══██╗██╔══╝ ██║██║╚██╗██║╚════██║██║██║ ██║██╔══██║ ██║
██║ ╚██████╔╝ ██║ ╚██████╔╝██║ ██║███████╗ ██║██║ ╚████║███████║██║╚██████╔╝██║ ██║ ██║
╚═╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═╝╚═╝ ╚═══╝╚══════╝╚═╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝
"Unlocking the Future, One Insight at a Time"
"
# Section: System Check
Write-Host "=== System Check ==="
Write-Host "Checking system status..."
# Check if git is installed
if (!(Get-Command git -ErrorAction SilentlyContinue)) {
Write-Host "❌ Git is not installed. Please install Git to use this script."
exit 1
}
Write-Host "✅ Git is installed."
Write-Host
# Section: Commit Message
Write-Host "=== Commit Message ==="
$message = Read-Host "✏️ Enter your commit message"
Write-Host
# Section: Git Add
Write-Host "=== Git Add ==="
git add .
Write-Host
# Section: Git Commit
Write-Host "=== Git Commit ==="
git commit -m $message
Write-Host
# Section: Check Commit Success
Write-Host "=== Check Commit Success ==="
if ($LASTEXITCODE -eq 0) {
Write-Host "Commit successful! 🎉"
}
else {
Write-Host "Commit failed. Please check your changes and try again. ❌"
exit 1
}
Write-Host
# Section: Push Commit
Write-Host "=== Push Commit ==="
$currentBranch = git rev-parse --abbrev-ref HEAD
$remoteBranch = git ls-remote --exit-code --heads origin $currentBranch
if ($remoteBranch) {
# Remote branch exists
Write-Host "🔗 Remote branch detected. Pushing commit..."
git push
Write-Host "Commit pushed successfully! 🚀"
}
else {
# Local branch exists
Write-Host "🌿 Local branch detected. Publishing branch..."
git branch --set-upstream-to=origin/$currentBranch $currentBranch
git push -u origin $currentBranch
Write-Host "Branch published and commit pushed successfully! 🚀"
}
Write-Host