Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save johnterickson/0467c3311d62fcbb1e81d90e38a68dff to your computer and use it in GitHub Desktop.
Save johnterickson/0467c3311d62fcbb1e81d90e38a68dff to your computer and use it in GitHub Desktop.
one-way git repo synchronization with shallow clone
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