Last active
July 4, 2023 07:38
-
-
Save erkobridee/c09222adb2180c3628b53a8f0994733c to your computer and use it in GitHub Desktop.
useful way to backup a whole repository from on remote to another remote server on an Unix base system
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
# define a full backup of a git repository from one remote server to another one | |
origin="https://remote-source/repository.git"; | |
target="https://remote-target/repository.git"; | |
workDir="temp-directory"; | |
mkdir $workDir | |
cd $workDir | |
git clone --mirror $origin . | |
git remote set-url --push origin $target | |
git show-ref | cut -d' ' -f2 | grep 'pull' | xargs -r -L1 git update-ref -d | |
git push --mirror | |
cd .. | |
rm -rf $workDir |
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
mkdir temp \ | |
&& cd temp \ | |
&& git clone --mirror https://remote-source/repository.git . \ | |
&& git remote set-url --push origin https://remote-target/repository.git \ | |
&& git show-ref | cut -d' ' -f2 | grep 'pull' | xargs -r -L1 git update-ref -d \ | |
&& git push --mirror \ | |
&& cd .. \ | |
&& rm -rf temp |
Author
erkobridee
commented
Jun 21, 2019
- Duplicating a repository | GitHub Help
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment