Created
April 24, 2018 08:35
-
-
Save JamesJJ/3f2bcb9bb2fda0e152aab34a55e12d45 to your computer and use it in GitHub Desktop.
Migrate 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
#!/bin/bash | |
#FROM="[email protected]:web/frontend.git" | |
#TO="ssh://[email protected]:22/WEB/_ssh/frontend" | |
[ -z "${FROM}" ] && exit 1 | |
[ -z "${TO}" ] && exit 1 | |
TEMPDIR="$(mktemp -d /tmp/git.XXXXXX)" | |
git clone --mirror "${FROM}" "${TEMPDIR}" && \ | |
cd "${TEMPDIR}" || exit 2 | |
git remote add new-target-origin "${TO}" && \ | |
git remote rm origin && \ | |
git remote rename new-target-origin origin && \ | |
git push --all origin && \ | |
git push --tags | |
cd - | |
[ "${TEMPDIR}" != "/" ] && rm -Rf "${TEMPDIR}" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment