-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit_ingest.sh
More file actions
executable file
·46 lines (38 loc) · 1.58 KB
/
git_ingest.sh
File metadata and controls
executable file
·46 lines (38 loc) · 1.58 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
#!/bin/bash
# This script creates a markdown file containing the full context of a git repository
# by exporting the directory structure and contents of all tracked files.
# It skips binary files, large files (>500KB), and specific files like pnpm-lock.yaml.
# The output file can be used by LLMs for repository-wide analysis, evaluation and refactoring.
OUTFILE="git_ingest_output.md"
echo -e "## Directory structure:\n" > "$OUTFILE"
git ls-files | grep -v -E '^\.cursor/|^\.documentation/' | tree --fromfile >> "$OUTFILE"
echo -e "\n\n## Files Content:\n" >> "$OUTFILE"
# List all Git tracked files, skipping ignored/untracked
git ls-files | while read -r file; do
# Skip .cursor and .documentation directories
if [[ "$file" =~ ^\.cursor/ ]] || [[ "$file" =~ ^\.documentation/ ]]; then
echo "Skipping directory: $file" >&2
continue
fi
# Skip pnpm-lock.yaml and .gitignore
if [[ "$file" == "pnpm-lock.yaml" ]] || [[ "$file" == ".gitignore" ]]; then
echo "Skipping file: $file" >&2
continue
fi
# Skip binary files
if [[ "$(file --mime "$file")" =~ binary ]]; then
echo "Skipping binary file: $file" >&2
continue
fi
# Skip large files (>500KB)
filesize=$(stat -f%z "$file" 2>/dev/null || echo 0)
if [ "$filesize" -gt 500000 ]; then
echo "Skipping large file: $file" >&2
continue
fi
echo -e "\n\n================================================" >> "$OUTFILE"
echo "FILE: $file" >> "$OUTFILE"
echo "================================================" >> "$OUTFILE"
cat "$file" >> "$OUTFILE"
done
echo -e "\n\n✅ Export complete: $OUTFILE"