Last active
January 18, 2019 10:04
-
-
Save marcocesarato/15b8cdfefe6662ac2cd9d3330c62df9f to your computer and use it in GitHub Desktop.
Multi commit for git repos with different branch but with same message
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
#!/usr/bin/env bash | |
: <<'DOC' | |
Directory structure: | |
MainFolder: | |
=> multicomnmit.sh | |
=> branch_name | |
=> repository_name | |
=> .git | |
---------------------------- | |
EXAMPLE: | |
---------------------------- | |
My_Repo: | |
=> multicomnmit.sh | |
=> branch1 | |
=> My_Repo | |
=> branch2 | |
=> My_Repo | |
DOC | |
REPOSITORY="My_Repo" # <==== Change IT !! | |
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" | |
MESSAGE="" | |
echo "" | |
echo "=======[ MultiCommit ]=======" | |
echo " Created by Marco Cesarato " | |
echo "-----------------------------" | |
echo " Multi branch commit for git " | |
echo "" | |
while [[ $MESSAGE = "" ]]; do | |
read -r -p "# [MultiCommit] Insert commit message: " MESSAGE </dev/tty | |
done | |
echo "" | |
for D in `find $SCRIPTPATH -type d -maxdepth 1` | |
do | |
BRANCHPATH="$D/$REPOSITORY/"; | |
if [ -d "$PLUGINPATH/.git" ]; then | |
DIRNAME="${D%"${D##*[!/]}"}" | |
DIRNAME=${DIRNAME##*/} | |
echo "" | |
echo "# [MultiCommit] Branch => $DIRNAME"; | |
cd $BRANCHPATH | |
git add -A | |
git commit -m "$MESSAGE" | |
git push origin $DIRNAME | |
cd ../ | |
fi | |
done | |
echo "" | |
echo "# [MultiCommit] End!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment