Created
April 3, 2023 10:07
-
-
Save meftunca/8e70341ac399fb1af3c8df6e16b9a0cb to your computer and use it in GitHub Desktop.
Automated script to create a new branch with the date and push changes for all projects with a .git folder in a specified directory.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Belirlenen dizin | |
DIRECTORY="/path/to/directory" | |
# Bugünün tarihi | |
DATE=$(date +"%Y%m%d") | |
# Tüm .git klasörlerinin listesi | |
GIT_DIRS=$(find "$DIRECTORY" -type d -name ".git") | |
# Her .git klasörü için | |
for GIT_DIR in $GIT_DIRS | |
do | |
# Proje dizini | |
PROJECT_DIR=$(dirname "$GIT_DIR") | |
# Değişiklikleri kontrol et | |
cd "$PROJECT_DIR" | |
CHANGES=$(git status --porcelain) | |
if [[ ! -z "$CHANGES" ]]; then | |
# Yeni bir branch oluştur ve pushla | |
BRANCH_NAME="update-$DATE" | |
git checkout -b "$BRANCH_NAME" | |
git add . | |
git commit -m "Update on $DATE" | |
git push origin "$BRANCH_NAME" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment