-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommit_and_push.sh
More file actions
41 lines (31 loc) · 874 Bytes
/
commit_and_push.sh
File metadata and controls
41 lines (31 loc) · 874 Bytes
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
#!/bin/bash
# chmod +x commit_and_push.sh
# ./commit_and_push.sh
# Parent folder containing your repositories
PARENT_DIR="/Users/user_name/folder"
BRANCH_NAME="feature/branch_name"
COMMIT_MSG="message"
# Loop through all subdirectories
for repo in "$PARENT_DIR"/*; do
if [ -d "$repo/.git" ]; then
echo "Processing repository: $repo"
cd "$repo" || continue
# Check for changes
if [ -n "$(git status --porcelain)" ]; then
echo "Changes found in $repo"
git status --porcelain
# Checkout branch
git checkout -b "$BRANCH_NAME" || continue
# Stage all changes
git add -A
# Commit
git commit -m "$COMMIT_MSG"
# Push
git push origin "$BRANCH_NAME"
else
echo "No changes in $repo"
fi
echo "----------------------------------------"
fi
done
echo "All repositories processed."