-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_pull.sh
More file actions
executable file
·50 lines (39 loc) · 1.1 KB
/
git_pull.sh
File metadata and controls
executable file
·50 lines (39 loc) · 1.1 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
#!/usr/bin/env bash
# ==============================================================================
# Git Helper Script
# File: git_pull.sh
#
# Purpose:
# Fetches and pulls the latest changes from origin for the current branch (fast-forward only).
# ==============================================================================
set -e
REPO_DIR="$(cd "$(dirname "$0")" && pwd)"
cd "$REPO_DIR"
echo "==============================="
echo " VEIN Git Pull Script"
echo "==============================="
echo
if [ ! -d ".git" ]; then
echo "❌ Kein Git-Repository gefunden."
exit 1
fi
BRANCH="$(git rev-parse --abbrev-ref HEAD 2>/dev/null || echo "")"
if [ -z "$BRANCH" ]; then
echo "❌ Konnte aktuellen Branch nicht ermitteln."
exit 1
fi
echo "Repo: $REPO_DIR"
echo "Branch: $BRANCH"
echo
echo "➡️ Fetch..."
git fetch --prune
LOCAL="$(git rev-parse HEAD)"
REMOTE="$(git rev-parse "origin/$BRANCH")"
if [ "$LOCAL" = "$REMOTE" ]; then
echo "ℹ️ Bereits aktuell (origin/$BRANCH)."
exit 0
fi
echo "➡️ Pull von origin/$BRANCH..."
git pull --ff-only
echo
echo "✅ Pull erfolgreich abgeschlossen."