Last active
March 16, 2022 05:21
-
-
Save hectorddmx/9602f678c777d38faeffb970f6c0d9ab to your computer and use it in GitHub Desktop.
Migrate self hosted repo with files bigger than 100 MB to github via git lfs
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/zsh | |
# Configure | |
CURRENT_ORG=SAMPLE_ORG | |
CURRENT_REPO=${PWD##*/} | |
# Track, fetch and pull all branches from previous host | |
git branch -r | grep -v '\->' | sed "s,\x1B\[[0-9;]*[a-zA-Z],,g" | while read remote; do git branch --track "${remote#origin/}" "$remote"; done | |
git fetch --all | |
git pull --all | |
# Adde new remote | |
git remote add github.com [email protected]:$CURRENT_ORG/$CURRENT_REPO | |
# Configure git lfs for this repo | |
git lfs install | |
# To review existing git lfs files | |
# git lfs ls-files | |
# To review files that will be migrated | |
# git lfs migrate info --everything --above=99Mb | |
git lfs migrate import --everything --above=99Mb | |
# First push for git lfs files | |
git push github.com --all --verbose --progress | |
# Second push to push all branches/tags | |
git push github.com --all --verbose --progress | |
# Upload all tags | |
git push github.com --tags --verbose --progress | |
# Make the console sound in macos to hear when it's finished | |
tput bel |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For future files