Created
January 18, 2019 15:11
-
-
Save marcocesarato/8c6a75dd70b463d1af1e07f12291f919 to your computer and use it in GitHub Desktop.
Multi pull for git
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 "=======[ MultiPull ]=======" | |
echo " Created by Marco Cesarato " | |
echo "-----------------------------" | |
echo " Multi branch pull for git " | |
echo "" | |
git submodule update --init --recursive | |
for D in `find $SCRIPTPATH -type d -maxdepth 1` | |
do | |
BRANCHPATH="$D/$REPOSITORY/"; | |
if [ -d "$BRANCHPATH/.git" ] || [ -f "$BRANCHPATH/.git" ]; then | |
DIRNAME="${D%"${D##*[!/]}"}" | |
DIRNAME=${DIRNAME##*/} | |
echo "" | |
echo "# [MultiPull] Branch => $DIRNAME"; | |
cd $BRANCHPATH | |
git checkout $DIRNAME | |
git fetch | |
git pull origin $DIRNAME | |
cd ../../ | |
fi | |
done | |
git checkout master | |
echo "" | |
echo "# [MultiPull] End!" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment