Eli-S commited on
Commit
659ff9d
·
unverified ·
1 Parent(s): 568f124

Added file ./add_and_push_files.sh

Browse files
Files changed (1) hide show
  1. add_and_push_files.sh +30 -0
add_and_push_files.sh ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+
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."
9
+ exit 1
10
+ fi
11
+
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
+
20
+ # Commit the file with a message, ignoring empty commits
21
+ git commit -m "Added file $file" || {
22
+ echo "Skipped empty commit for $file"
23
+ continue
24
+ }
25
+
26
+ # Push the commit to the remote repository
27
+ git push
28
+
29
+ echo "Processed $file"
30
+ done