Skip to content

Instantly share code, notes, and snippets.

@papachristoumarios
Created October 7, 2019 15:07
Show Gist options
  • Save papachristoumarios/61a96cadd04cdcea69942879177a8afd to your computer and use it in GitHub Desktop.
Save papachristoumarios/61a96cadd04cdcea69942879177a8afd to your computer and use it in GitHub Desktop.
Git LFS Sync between remotes
#!/bin/bash
# Sync two git LFS remotes. This is very useful when you
# have two remotes (e.g. upstream and fork) and they have
# different files on the LFS storage. Trying git lfs fetch --all
# yields an error for missing objects if the two repos are not
# synced. The purpose of this script is to overcome this issue
# with Git LFS
#
# Usage: git-lfs-sync.sh source destination branch
#
# Author: Marios Papachristou
SOURCE=`git remote get-url $1`
DEST=`git remote get-url $2`
echo "Changing lfs.url"
git config -f .lfsconfig lfs.url "$SOURCE/info/lfs"
git fetch --all
echo "Syncing"
git config lfs.allowincompletepush true
git config -f .lfsconfig lfs.url "$DEST/info/lfs"
git push --all $2 $3
git config lfs.allowincompletepush false
echo "Complete"
@Iskanderlm
Copy link

You saved my life.
I was considering just giving up and starting the entire project over but you saved me!
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment