-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove-docker-data-from-git.sh
More file actions
54 lines (44 loc) · 1.79 KB
/
remove-docker-data-from-git.sh
File metadata and controls
54 lines (44 loc) · 1.79 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
#!/bin/bash
# Remove docker/data from git tracking (permanent solution)
# This script removes docker/data files from git index without requiring file access
set -e
REPO_DIR="/home/skumar/DaatScience/Sentinel"
cd "$REPO_DIR"
echo "Removing docker/data/ from git tracking..."
echo ""
# Get list of files to remove
echo "Collecting docker/data files from git index..."
git ls-files docker/data/ > /tmp/docker_data_files.txt 2>/dev/null || echo "" > /tmp/docker_data_files.txt
FILE_COUNT=$(wc -l < /tmp/docker_data_files.txt | tr -d ' ')
if [ "$FILE_COUNT" -eq "0" ]; then
echo "✅ No docker/data files tracked by git. Already clean!"
exit 0
fi
echo "Found $FILE_COUNT files to remove. Processing in batches..."
# Split into batches to avoid command line length issues
cat /tmp/docker_data_files.txt | split -l 1000 - /tmp/batch_ 2>/dev/null || {
# If split fails, process all at once
cat /tmp/docker_data_files.txt | git update-index --force-remove --stdin 2>&1 | grep -v "error\|fatal" || true
exit 0
}
# Process each batch
BATCH_COUNT=0
for batch in /tmp/batch_*; do
BATCH_COUNT=$((BATCH_COUNT + 1))
echo "Processing batch $BATCH_COUNT..."
cat "$batch" | git update-index --force-remove --stdin 2>&1 | grep -v "error\|fatal" || true
done
# Cleanup temp files
rm -f /tmp/docker_data_files.txt /tmp/batch_* 2>/dev/null || true
# Verify removal
REMAINING=$(git ls-files docker/data/ 2>/dev/null | wc -l || echo "0")
if [ "$REMAINING" -eq "0" ]; then
echo ""
echo "✅ Successfully removed all docker/data/ files from git tracking!"
echo " You can now commit without permission issues."
else
echo ""
echo "⚠️ Warning: $REMAINING files still tracked."
echo " You may need to run: sudo chown -R skumar:users docker/data/"
echo " Then run this script again."
fi