Skip to content

Instantly share code, notes, and snippets.

@terranc
Created August 10, 2016 15:13
Show Gist options
  • Select an option

  • Save terranc/a87139f16fc3fdd6f219457545d34571 to your computer and use it in GitHub Desktop.

Select an option

Save terranc/a87139f16fc3fdd6f219457545d34571 to your computer and use it in GitHub Desktop.
同步两个git库
#!/bin/sh
GIT_REPO=/mnt/www/github_tmp_repo
##GITLab
GIT="xxx.git"
GITLAB_GROUP="xxx"
GITLAB_GIT="git@git.xxx.io:${GITLAB_GROUP}/${GIT}"
#GITHub
GITHUB_ORG="xxxx"
GITHUB_GIT="https://github.com/${GITHUB_ORG}/${GIT}"
echo "/-------------------------------------------------"
echo "gitlab:${GITLAB_GIT}"
echo "github:${GITHUB_GIT}"
echo "begin_time:"`date`
#Temp Dir
GIT_DIR=${GIT_REPO}/${GIT}
cd ${GIT_REPO}
rm -rf ${GIT_DIR}
echo `git clone --bare ${GITHUB_GIT}`
echo "clone result:"$?
cd ${GIT_DIR}
#../../git-author-rewrite.sh
git push --mirror ${GITLAB_GIT}
echo "push result:"$?
cd ..
rm -rf ${GIT_DIR}
echo "end_time:"`date`
echo "\-------------------------------------------------"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment