Created
October 7, 2019 15:07
-
-
Save papachristoumarios/61a96cadd04cdcea69942879177a8afd to your computer and use it in GitHub Desktop.
Git LFS Sync between remotes
This file contains hidden or 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
#!/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" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You saved my life.
I was considering just giving up and starting the entire project over but you saved me!
Thank you!