Created
March 4, 2025 18:47
-
-
Save johnterickson/0467c3311d62fcbb1e81d90e38a68dff to your computer and use it in GitHub Desktop.
one-way git repo synchronization with shallow clone
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
export DESTINATION=[git URL] | |
export SOURCE=[git URL] | |
export BRANCH=main | |
# shallow clone of the destination - this should be at or behind the source | |
git clone --no-tags --progress --no-recurse-submodules --depth=1 $DESTINATION | |
git checkout $BRANCH | |
# add the source | |
git remote add source $SOURCE | |
# fetch only the delta | |
git fetch source $BRANCH | |
git merge refs/remotes/source/$BRANCH --ff-only | |
git push HEAD:$BRANCH --force |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment