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 |
For future files
# Install git lfs in the current repo
git lfs install
# Add the following tracks
git lfs track "**/*.framework/**"
git lfs track "**/*.xcframework/**"
git lfs track "*.a"
git lfs track "*.pak"
git lfs track "*.dylib"
git lfs trakc "*.bin"
git lfs track "*.zip"
git lfs track "*.7z"
git lfs track "*.mp4"
git lfs track "*.png"
git lfs track "*.jpg"
git lfs track "*.jpeg"
git lfs track "*.sketch"
git lfs track "*.fig"
# If you have specific files that don't have an extension, you can add it with this command:
git lfs track --filename "Chromium Embedded Framework"
# Add to staging this new file called .gitattributes that contains the list of files that will be tracked:
git add .gitattributes
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Review if there are big files (no git lfs needed)