Eli-S commited on
Commit
27c67cd
1 Parent(s): 659ff9d

Added file ./add_and_push_files.sh

Browse files
Files changed (1) hide show
  1. add_and_push_files.sh +21 -0
add_and_push_files.sh CHANGED
@@ -3,6 +3,9 @@
3
  # Set the directory to search for files (current directory by default)
4
  TARGET_DIR=${1:-.}
5
 
 
 
 
6
  # Check if the directory exists
7
  if [ ! -d "$TARGET_DIR" ]; then
8
  echo "Directory $TARGET_DIR does not exist."
@@ -12,8 +15,20 @@ fi
12
  # Navigate to the target directory
13
  cd "$TARGET_DIR" || exit
14
 
 
 
 
15
  # Find all files recursively
16
  find . -type f | while read -r file; do
 
 
 
 
 
 
 
 
 
17
  # Add the file to the Git staging area
18
  git add "$file"
19
 
@@ -28,3 +43,9 @@ find . -type f | while read -r file; do
28
 
29
  echo "Processed $file"
30
  done
 
 
 
 
 
 
 
3
  # Set the directory to search for files (current directory by default)
4
  TARGET_DIR=${1:-.}
5
 
6
+ # Set the size threshold for using Git LFS (in bytes, e.g., 10MB)
7
+ LFS_THRESHOLD=$((10 * 1024 * 1024)) # 10MB
8
+
9
  # Check if the directory exists
10
  if [ ! -d "$TARGET_DIR" ]; then
11
  echo "Directory $TARGET_DIR does not exist."
 
15
  # Navigate to the target directory
16
  cd "$TARGET_DIR" || exit
17
 
18
+ # Ensure Git LFS is initialized
19
+ git lfs install --skip-smudge
20
+
21
  # Find all files recursively
22
  find . -type f | while read -r file; do
23
+ # Get the file size in bytes
24
+ FILE_SIZE=$(stat --format=%s "$file")
25
+
26
+ if [ "$FILE_SIZE" -ge "$LFS_THRESHOLD" ]; then
27
+ # Track the file with Git LFS
28
+ git lfs track "$file"
29
+ echo "Tracked large file with LFS: $file"
30
+ fi
31
+
32
  # Add the file to the Git staging area
33
  git add "$file"
34
 
 
43
 
44
  echo "Processed $file"
45
  done
46
+
47
+ # Commit and push the updated .gitattributes file (if any)
48
+ if git diff --cached --name-only | grep -q '.gitattributes'; then
49
+ git commit -m "Updated .gitattributes for LFS" || echo "No changes to .gitattributes"
50
+ git push
51
+ fi