Last active
August 28, 2020 12:51
-
-
Save pixelbrackets/13c5cca26ea806c6386bf5e8f18bac7c to your computer and use it in GitHub Desktop.
Duplicate / Mirror a git repository to another without forking
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 | |
# Usage: | |
# ./git-mirror-repository.sh "<source repository URL>" "<target repository URL>" | |
# Example: | |
# ./mirror-gitlos-project.sh "git@gitlab.com:example/kickstart.git" "git@gitlab.com:example/acme.git" | |
# | |
# The user must have access to both existing repositories | |
# | |
# Warning! --mirror will do a force push - Use only once per project! | |
echo "Mirror project $1" | |
cd $(mktemp -d) | |
pwd | |
git clone --mirror $1 | |
cd $(ls -d */ | head -n 1) | |
git push --mirror $2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment