Created
September 13, 2016 17:58
-
-
Save ip2k/6e1e4a1d6996bdb010b1f420ea3fa6a0 to your computer and use it in GitHub Desktop.
Mirror git repos via pull. Grabs all commits, tags, branches, etc and only grabs changes once the initial pull-down is complete.
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 | |
REPO_BASE_URL='ssh://git@repo.example.com:1234/some-project-space' | |
REPOS='foo bar baz quux' | |
echo -e "\e[1;95;102mStarted at $(date) \e[0m" | |
BASEDIR="${PWD}" | |
for repo in $REPOS; do | |
dirname="${repo}.git" | |
echo -e "Now processing \e[1;95m${dirname}\e[0m" | |
cd ${BASEDIR} | |
if [[ -d "${dirname}" ]]; then | |
echo -e "\e[1;32mFound existing git repo\e[0m" | |
cd "${dirname}" | |
git remote --verbose update --prune | |
retval=$? | |
else | |
echo -e "\e[1;36mNo existing git repo; will clone.\e[0m" | |
url="${REPO_BASE_URL}/${dirname}" | |
mkdir "${dirname}" | |
cd "${dirname}" | |
git clone --mirror "${url}" . | |
retval=$? | |
fi | |
[[ $retval > 0 ]] && echo -e "\e[1;41;97mError processing ${dirname}\e[0m" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment