Skip to main content

Exporting files to Git LFS

When migrating from XetHub to another Git provider, you will need to use Git LFS if your repository contains any large files. Large file limits vary per Git provider:

The steps below will migrate the latest version on the main branch of a XetHub repository to a new Git provider that uses Git LFS for large files. Additional branches from your XetHub repository will not be migrated, nor will the repository history.


Local setup

If you do not have Git LFS installed, follow the instructions to install it now.

From your XetHub repository, merge anything you want to transfer into the latest version of the main branch. This could mean moving files from branches into main branch directories or simply ensuring that all open pull requests have merged into main. Once all files are in main, clone your XetHub repository locally and note the directory path.

Create an empty repository using your new Git provider, clone it locally, and note the directory path.

Copy files to new repository

Copy the contents of the locally cloned XetHub directory into the empty directory for the new Git repository. While copying, make sure to ignore the .git and .gitattributes folders as copying these will cause conflicts with your new Git provider. We recommend using the rsync command below, replacing the placeholder paths appropriately:

rsync -av --exclude='.git' --exclude='.gitattributes' /path/to/xethub/repo/ /path/to/new/repo/

In your terminal, navigate to the directory containing new Git repository and confirm all of the files have been added.

Track files with Git LFS

Once all files are present, run the following from the root diretory of the new repository:

git lfs install

You should see a message confirming that the repository's Git hooks have been updated and Git LFS is initialized.

By default, Git LFS will not track any files. If there is a specific file type you would like to track with Git LFS, note its extension and use the git lfs track command to begin tracking all files of that type. The example below adds all Parquet files to Git LFS; you can replace the parquet extension with any other file type to begin tracking those files:

git lfs track "*.parquet"

If you only need to track specific files and not all files of a certain type, use the path to that file to add it to Git LFS's tracking. The example below adds the data.csv file, but no other CSV files are tracked:

git lfs track path/to/data.csv

Now that your new repository has all desired files, add them to Git using git add . and then confirm that Git LFS is tracking the desired files. Running the following command should print the names of all Git LFS tracked files:

git lfs ls-files -n

If Git LFS is not tracking all desired files, target the files or extensions you wish to add with the git lfs track command as described above.

Commit and push to the remote repository

Finally, commit all added files:

git commit -m "Initial copy of XetHub repository contents"

And push the commit to the remote repository:

git push -u origin main