Skip to content

Instantly share code, notes, and snippets.

@JamesJJ
Created April 24, 2018 08:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JamesJJ/3f2bcb9bb2fda0e152aab34a55e12d45 to your computer and use it in GitHub Desktop.
Save JamesJJ/3f2bcb9bb2fda0e152aab34a55e12d45 to your computer and use it in GitHub Desktop.
Migrate GIT
#!/bin/bash
#FROM="git@hichub.example.com:web/frontend.git"
#TO="ssh://exampleengineering@vs-ssh.visualstudio.com: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