Type something to search...

Migrate a GitHub LFS (Git Large File Storage) repository to AWS CodeCommit

I recently migrated one of my GitHub repositories, which uses Git Large File Storage (LFS), over to AWS CodeCommit. I thought I'd share the process with you in case you’re looking to do something similar. Here's a step-by-step guide based on my experience.

Prerequisites

Before we get started, make sure you have these tools installed:

  • Git
  • Git LFS
  • AWS CLI

Step-by-Step Guide

1. Clone the Repository

First, clone your GitHub repository using the --mirror option. This creates a bare clone of the repository, including all branches and tags.

git clone --mirror https://github.com/tanshuai/designs.git designs

2. Verify LFS Files

Next, list all files managed by Git LFS to ensure everything is in place.

git lfs ls-files

You should see something like this:

cadfa0bc9e * Brochure-Trifold-Draft.ai
af9b8b8a1c * Brochure-Trifold-English.ai
27bb5f4e61 * Brochure-Trifold.ai

3. Migrate LFS Files

Now, export the LFS files. This step makes sure they are part of your repository’s history.

git lfs migrate export --include="*.ai" --everything

You'll see some progress messages like these:

migrate: Sorting commits: ..., done.
migrate: Rewriting commits: 100% (20/20), done.
master	98a3c48d85... -> 82f8873b41...
migrate: Updating refs: ..., done.
migrate: checkout: ..., done.
prune: 3 local object(s), 0 retained, done.
cadfa0bc9e... (133 MB)
27bb5f4e61... (131 MB)
af9b8b8a1c... (130 MB), done.
prune: Deleting objects: 100% (3/3), done.

4. Clean Up LFS

Remove the Git LFS tracking information and uninstall Git LFS.

git lfs ls-files
git rm .gitattributes -f
git lfs uninstall

5. Push to AWS CodeCommit

Finally, push your repository to AWS CodeCommit.

git push https://git-codecommit.us-east-2.amazonaws.com/v1/repos/designs --all

That’s it! By following these steps, I successfully migrated my GitHub LFS repository to AWS CodeCommit. The large files and the repository history were preserved perfectly.

Wrapping Up

Migrating a GitHub repository that uses Git LFS to AWS CodeCommit is pretty straightforward if you follow the right steps. If you have any questions or run into issues, the AWS CodeCommit documentation and Git LFS documentation are great resources.

I hope you find this guide helpful. Happy coding!

Share :

Related Post

AWS CodeCommit: The GitHub Large File Storage (Git LFS) Free Alternative

AWS CodeCommit offers a robust alternative to GitHub's Large File Storage (Git LFS) service, providing an efficient solution for managing large files in your Git repositories. Why You Should Reco

Read More

Quickly Convert Markdown to Academic-Style Paper PDF on macOS

In this guide, I'll walk you through how I convert Markdown documents to academic-style paper PDFs on macOS using Pandoc and BasicTeX. This method is quick and straightforward, perfect for when you n

Read More

Electron Build Tools `ERROR Error: Failed to run "choco install pywin32 --yes"`

When working with Electron Build Tools, you might encounter an error related to the installation of pywin32 via Chocolatey. This can be frustrating, especially when it's a required dependency for you

Read More

Get current commit id of Git and update to package.json

When developing a Node.js project, you may want to keep track of the current commit ID of your Git repository. This information can be useful for debugging, versioning, or deployment purposes. One wa

Read More

Reset/Restore All subdirectories of Git

Managing a Git repository effectively often requires resetting or restoring subdirectories to maintain a clean and functional codebase. This guide provides a concise, step-by-step approach to reset o

Read More