-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-sync-helper.sh
More file actions
81 lines (75 loc) · 2.4 KB
/
git-sync-helper.sh
File metadata and controls
81 lines (75 loc) · 2.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
#!/bin/bash
# Git Sync Helper for Replit
# This script helps sync your local changes with remote GitHub repository
echo "🔄 Aequitas Protocol - Git Sync Helper"
echo "======================================"
echo ""
# Show current status
echo "📊 Current Status:"
git log --oneline -3
echo ""
echo "🌐 Remote Status:"
git log --oneline origin/main -3
echo ""
# Check if we're ahead of remote
AHEAD=$(git rev-list --count origin/main..HEAD)
BEHIND=$(git rev-list --count HEAD..origin/main)
echo "📈 Your local repository is:"
echo " - $AHEAD commits AHEAD of remote"
echo " - $BEHIND commits BEHIND remote"
echo ""
if [ "$BEHIND" -gt 0 ]; then
echo "⚠️ You need to pull remote changes first!"
echo ""
echo "Options:"
echo "1. Pull and merge: git pull origin main --no-rebase"
echo "2. Pull and rebase: git pull origin main --rebase"
echo "3. Force push (DANGEROUS): git push origin main --force"
echo ""
echo "Recommended: Option 1 (pull and merge)"
echo ""
read -p "Enter option number (1-3) or 'q' to quit: " choice
case $choice in
1)
echo "🔄 Pulling and merging..."
git pull origin main --no-rebase
if [ $? -eq 0 ]; then
echo "✅ Pull successful! Now pushing..."
git push origin main
else
echo "❌ Pull failed. Please resolve conflicts manually."
fi
;;
2)
echo "🔄 Pulling and rebasing..."
git pull origin main --rebase
if [ $? -eq 0 ]; then
echo "✅ Rebase successful! Now pushing..."
git push origin main
else
echo "❌ Rebase failed. Please resolve conflicts manually."
fi
;;
3)
echo "⚠️ FORCE PUSH - This will overwrite remote changes!"
read -p "Are you ABSOLUTELY sure? (type 'YES' to confirm): " confirm
if [ "$confirm" = "YES" ]; then
git push origin main --force
echo "✅ Force push complete"
else
echo "❌ Cancelled"
fi
;;
q|Q)
echo "Exiting..."
exit 0
;;
*)
echo "Invalid option"
exit 1
;;
esac
else
echo "✅ You're up to date with remote. Safe to push!"
git push origin main
fi